2012年1月16日 星期一

9 件創業教我的事

轉貼! 要時時提醒自己!
原連結

HitPlay 的創辦人 Joshua Seims 在他的網誌上分享了一篇 9 Things I Learned by Starting a Company,我覺得跟我的經驗非常像,所以今天就從他的 9 個點出發,跟大家聊聊我自己的心得。

1. 恐懼是可以被克服的

創業的恐懼有兩種,一種是不敢面對、害怕丟臉的恐懼,一種是擔心結果不如預期的恐懼。怕丟臉的恐懼讓你裹足不前,不敢嘗試。開始嘗試了,還有害怕失望的恐懼讓你心情忽高忽低,無法冷靜判斷。這兩個好像每顆心與生俱來都會有的弱點,但創業的經驗告訴我它們其實可以被克服。
要克服不敢的恐懼,很簡單,它就像克服酒量一樣,唯一的方法就是一直喝、不斷的喝,喝到什麼最噁心的嘔吐你都經歷過、什麼最慘痛的失敗你都體驗過,然後有一天,你就會發現自己無敵了。要克服害怕失望的恐懼也很簡單,那就是不要有期望。記得幸運的人嗎?當你放棄了既定的目標,那你不但永遠不會失望,還會因此在路上多撿到許多機會,多好!

2. 天長地久不如真的擁有

當你在當員工時,你就像一隻狗、一個奴才。做不好,通通都是你該死。做得好,通通都是老闆英明。而創業和「Ownership」,就是你的解放,讓你真正擁有你在做的事情、真正決定自己的未來。沒有人說這是一件容易的事情,事實上,當員工的話 6 點就下班了,Server 掛掉是你家的事。當老闆,抱歉,永遠沒有鬆懈的一秒鐘,你連作夢都還在想公司的事。但同時,你也擁有那種握住的感覺,那種過自己的人生,而不是幫別人抬轎的踏實感。

3. 為自己負責

既然沒有了老闆,你就被迫要學會獨立作戰、獨立思考,做自己的決定,並且為自己的選擇負責。一開始會有點不習慣,你會發現自己到處問別人的意見,因為我們從小都沒有學過如何「做自己」。不過一旦你開始抓到了絕竅,就會化身為真正自由的個體,這世界雖千萬人,在也沒辦法擋住你要去哪裡。

4. 沒有 Co-founder 是很孤獨的

當你自己一個人挑戰這個世界,即使是心臟再強、臉皮再厚的創業者,也會有無法承受創傷的一天。你需要一些伙伴,一些跟你擁有相同志向的人,才能在最失落的時候,擁有一個背後的靠山。

5. 通路勝過產品

「把產品做出來,他們就會來」是全世界最大的騙局,至少對於 99.9% 的創業者是這樣的。你最重要的武器,是在把產品做出來前,就先開始著手布建一個有效的通路。產品可以一直換,但通路,才是拿不走的東西。

6. 你成功的秘密,當然不是大家都知道的事情

成功的商業模式絕對不是想出來的,當然更不是分析出來的,否則在你之前,早就有 1,000 個人想到了。當你去看歷史上成功的商業模式,基本上全部都是矇到、Pivot 出來的。如果是這樣,那你除了要有超人的分析,還要有超強的「製造意外」能力。

7. 團隊是超級重要的事情

前面 10 個員工,決定了你公司的文化,所以你必須要花很多、是很多時間在這上面。記住:能力可以學,態度則是你無法改變的。千萬不要用兩次面試,就決定了一切。結婚之前,多約幾次會,甚至同居一陣子,搞清楚了彼此的個性,再私訂終身,也還不遲。

8. 名譽才是你最重要的資產

相信我,創業 13 年來,熱錢來來去去、市場起起伏伏、團隊分分合合我看太多了。到最後,每個人在你心中的地位,就只剩他的品德和人格。你要想清楚,這是一場一輩子的賽局,千萬不要為了短期的利益,犧牲了你一輩子的名譽。如果你行得直、坐得正,那就會吸引來一群一樣欣賞這個風格的夥伴,那,才是永遠拿不走,最最重要的資產。

9. 如果你不覺得好玩,那還是別搞了吧

我看過太多人因為「機會很好」,所以創業,但打從心底,他們並不享受這個過程。可惜創業失敗的機率是遠高過成功的,所以這些人往往不但賠了夫人,還回過頭怨恨自己當初的選擇。人生只有一次,創業不但是在建立一個事業,更是在找到自我價值的實現。
Steve Jobs 說的:
每天早上,我看著鏡子然後問我自己:「如果今天是我人生的最後一天,我會想要做我正要去做的事情嗎?」如果答案連續好幾天都是「No」,那我就知道我必須要改變些什麼。
以上,與大家共勉。
PS. 感謝大家支持昨天的一人一信行動,24 小時內,該篇文章累積了 25,000 人次閱覽,並且有 2,000 人因此連結到總統信箱開始寫信,假設最後的轉換率有 20%,那表示我們總共寄出了約 400 封信給馬先生,大大超過了我希望的 100 封,所以算是一次非常成功的行動,也希望我們能夠很快的收到一些正面的回應。

2012年1月11日 星期三

Intrinsic functions

MS provide some intrinsic functions for low level operations (eg. firmware/driver) on their compiler that is very convenience. You don't have to include the any header file to make use of these functions. But you have to specify a compiler option "/Oi".
example:
#progma intrinsic (func1)
#progma intrinsic (func2, func3)

Below are some of intrinsic functions

_disable
_outp
fabs
strcmp
_enable
_outpw
labs
strcpy
_inp
_rotl
memcmp
strlen
_inpw
_rotr
memcpy
_lrotl
_strset
memset
_lrotr
abs
strcat

2012年1月10日 星期二

PCD 類型介紹

主要分為五種類型

  1. FIX_AT_BUILD : 類似C 裡面的const
  2. PATCHABLE_IN_MODULE: 類似EFI裡的variable, 存在flash 裡, 可以用工具程式修改PatchPcdValue.exe GenPatchPcdTable.exe
  3. DYNAMIC: 類似C裡面的變數, 執行期間可修改, 但是關機會消失
  4. DYNAMIC_EX:和DYNAMIC一樣,只是要多傳一個參數 TokenSpaceGuid
  5. FEATURE:用於platform building時用於替代!ifdef !endif 

原文網址

2012年1月9日 星期一

EDK2 image generate stages

Step 1: Process Meta-Files  start from Module Top-level dsc file. Then .fdf files then list of inf files to generate multiple level of makefile
Step 2: Start Compiling with nmake/gunmake recursively to generate COFF/PE32 files then execute GenFW to convert to EFI image files
Step 3. If top-level .dsc file contain define of
            FLASH_DEFINITION = XXXX.fdf
            then will invoke gendfs to generate final image file. If no such definition, step 3 will not go. (For those only hope to generate EFI application or driver, can use -m parameter to specify a XXX.inf which should already be listed in top-level dsc file to only compile that specific module)

2012年1月7日 星期六

EFI 開機碟製作 (UFD)

format UFD to FAT
put shell.efi you build or get from UDK to
\efi\boot\

rename to:
ia32 arch==>bootia32.efi
x64 arch===>bootx64.efi

----------------------------------
another note for edk build command parameter
-a IA32/X64/IPF
-t VS2008/VS2008x86 etc
-b RELEASE/DEBUG
-p platform descriptor file  etc Nt32Pkg\Nt32Pkg.dsc
-m module  build a specific module in platform descriptor
-n CPU thread number (can speed up build time!)
-j logfile.txt specify the logfile
Build tools default use /conf/tools.def.txt to define used tools.
default tools chain is MYTOOLS which direct to VS2008 which you should manually modify if you are using another tools.
If you are going to build Nt32pkg, since this is a simulator on win32 environment. It will link to some window library. Therefore you should setup building environment to a specific by passing a "--nt32" parameter when running DOS batch file edksetup.bat.

2012年1月4日 星期三

MBR and GPT

MBR (Master Boot Record) 舊式 Legacy 時代的啟動磁區
共512 byte
前446 byte 是bootloader code
接著 64byte 紀錄4個 partition table 各 16 byte
最後兩個byte是 0x55AA
單一partition最大2TB

GPT(GUID partition table)
EFI 規格的一部分, 只有EFI BIOS才有支援
GPT  table 以LBA(logical block)為單位 1 LBA = 512 BYTE
LBA 0 是 protective MBR
In the GPT specification, the location corresponding to the MBR in MBR-based disks is structured in a way that prevents MBR-based disk utilities from mis-recognizing, and possibly over-writing, GPT disks. This is referred to as a "protective MBR"  In operating systems that support GPT-based boot, it is also used to store the first stage of the bootloader code. A single partition type of 0xEE, encompassing the entire GPT drive, is indicated and identifies it as GPT. 
LBA 1 Partition Table Header

The partition table header defines the usable blocks on the disk. It also defines the number and size of the partition entries that make up the partition table. On 64-bit Windows Server 2003 machines, 128 partitions can be created. There are 128 partition entries reserved, each 128 bytes long. (The EFI specification requires that a minimum of 16,384 bytes be reserved for the partition table, so this gives space for 128 partition entries.)
The header contains the disk GUID (Globally Unique Identifier). It records its own size and location (always LBA 1) and the size and location of the secondary GPT header and table (always the last sectors on the disk). Importantly, it also contains a CRC32 checksum for itself and for the partition table, which may be verified by the firmware, bootloader and/or operating system on boot. Because of this, hex editors should not be used to modify the contents of the GPT. Such modification would render the checksum invalid. In this case, the primary GPT may be overwritten with the secondary one by disk recovery software. If both GPTs contain invalid checksums, the disk would be unusable.

LBA 2~33
128BYTES per partition 
LBA = 4 Partition 
total 4X32=128 partitions
Each partition cap to 8 ZB

Linux I/O access function

In most  systems, I/O access can divided into 2 schemes.
1. memory map I/O
2. I/O port access
Most desktop/notebook seperate I/O space and memory space. To access via I/O need another instructions
ex. in/out
But for most embedded system, I/O is mapped to memory space.

so we have 2 methods to access external device via I/O depends on the platform you choose.
Here i write down the sequence and function for both I/O access method.

1. Memory access
     request_mem_region() -> ioremap -> readb() writeb() -> iouremap() -> release_mem_region()

2. I/O port access
    request_region() -> inb() outb() -> release_region()

2012年1月2日 星期一

asmlinkage 用法


"asmlinkage" 是在 i386 system call 實作中相當重要的一個 gcc 標籤(tag)。
當 system call handler 要呼叫相對應的 system call routine 時,便將一般用途暫存器的值
push 到 stack裡,因此 system call routine 就要由 stack 來讀取 system call handler 傳遞的
參數。這就是 asmlinkage標籤的用意。
system call handler 是 assembly code,system call routine(例如:sys_nice)是 C code,
當 assembly code 呼叫 C function,並且是以 stack 方式傳參數(parameter)時,
在 C function 的 prototype 前面就要加上 "asmlinkage"。
加上 "asmlinkage" 後,C function 就會由 stack 取參數,而不是從 register 取參數(
可能發生在程式碼最佳化後)。
更進一步的說明...
80x86 的 assembly 有 2 種傳遞參數的方法:
1. register method
2. stack method
Register method 大多使用一般用途(general-purpose)暫存器來傳遞參數,這種
方法的好處是簡單且快速。另外一種傳遞參數的做法是使用 stack(堆疊),
assembly code 的模式如下:
push number1
push number2
push number3
call sum
在 'sum' procedure 裡取值的方法,最簡單的做法是:
pop ax
pop ax
pop bx
pop cx
Stack Top 是放 IP,我們傳給 sum procedure 的參數由 stack 的後一個 entry 開始
讀取。
其它有關 asmlinkage
1. asmlinkage 是一個定義
2. "asmlinkage" 被定義在 /usr/include/linux/linkage.h
3. 如果您看了 linkage.h,會發現 "__attribute__" 這個語法,這是 gcc 用來定義
 function attribute 的語法。
轉貼自Jollen blog

2012年1月1日 星期日

利用find shell command 找檔案

普通用法
find -inamme *.c
這樣會把現在所在目錄下以及子目錄下的.c 檔列在螢幕上
高級用法
可以把輸出轉向到另一個指令的輸入
ex.
find -iname *.c -exec grep -l MEM_LENGH {} \;
會列出所有.c 裡有包含MEM_LENGH的檔案名稱