robot
最新文章(10)
Mqskit 和其它相關工具
CPython 的 GC 二、三事
寫 Mecurial Extension 是件快樂的事!
Mozilla 台灣辨公室徵人啟事
關於 Apple 的兩項專利
core dump 之前的 frame
怎麼發出 beep 聲?
先承認你要找的是奴才吧!
程式碼要清的多乾淨?
FreeBSD 的 Thread-Local Storage 實作
首頁
新編
最新留言
Entries RSS
重要關鍵字(10)
coding (122)
Python (93)
FreeBSD (71)
WEB (61)
URL (48)
hardware (46)
javascript (36)
Linux (34)
blog (30)
C++ (16)
所有關鍵字
新增 URL
FreeBSD 基礎建設 - libstand
by thinker
2 Columns
關鍵字:
coding
FreeBSD
在 $FreeBSD$ ,如果你下指令 {{{ man libstand }}} 你會發覺 libstand 似乎是很好用的工具。 libstand 提供許多常用的 libc function ,讓我們在沒有作業系統 support 時,無法執行一般的 libc 時,提供一個接近於 libc 的環境。我們只需要做些簡單的設定,就可以直接使用。 承接前一篇 linkname:[$FreeBSD$ 基礎建設 - BTX] http://heaven.branda.to/~thinker/GinGin_CGI.py/show_id_doc/180 ,我做些小修改,使用 libstand 的 printf() 和 twiddle() 功能。 {{{ # helloworld.c #include <stand.h> #include "btxv86.h" /* following are functions that is needed by libstand */ int getchar(void) { } int ischar(void) { return 0; } void putchar(int c) { __v86.ctl = 0; __v86.addr = 0x10; __v86.eax = 0x0e00 | c; __v86.ebx = 0x0000; v86int(); } int devopen(struct open_file *of, const char *name, const char **file) { } int devclose(struct open_file *of) { } void panic(const char *msg, ...) { } void init_heap(void) { } struct fs_ops *file_system[] = { NULL }; struct devsw *devsw[] = { NULL }; int main(int argc, char **argv) { int i; printf("hello world!!\r\n"); while(1) { for(i = 0; i < 102400; i++); twiddle(); } return 0; } int exit(int d) { } }}} {{{ # Makefile PROG= helloworld.sym SRCS= helloworld.c CFLAGS= -I/usr/src/sys/boot/i386/btx/lib LDFLAGS= -static -Ttext 0x0 -nostdlib OBJS= /usr/obj/usr/src/sys/boot/i386/btx/lib/crt0.o LDADD= -lstand MAN= BTXLDR= /usr/obj/usr/src/sys/boot/i386/btx/btxldr/btxldr BTXKERN= /usr/obj/usr/src/sys/boot/i386/btx/btx/btx CLEANFILES= helloworld helloworld.bin all: helloworld helloworld: helloworld.bin btxld -v -f aout -e 0x200000 -o $${.TARGET} -l $${BTXLDR} \ -b $${BTXKERN} helloworld.bin helloworld.bin: helloworld.sym cp $${.ALLSRC} $${.TARGET} strip -R .comment -R .note $${.TARGET} .include <bsd.prog.mk> }}} == 結論 == 只需提供一些 function 和設定一些資料,我們就可以有常用的 libc function 可用。這讓無 OS 環境的 programming ,更加的容易。
最後更新時間: 2006-12-27 01:27:05 CST |
引用
查詢:
COMMENTS: