顯示具有 FreeBsd 標籤的文章。 顯示所有文章
顯示具有 FreeBsd 標籤的文章。 顯示所有文章

星期二, 5月 18, 2010

Linux中的Type with Constant Length

許久以來,programming時常看到一堆類似的type define.

今天剛好用到,就整理一下嘍













---------------------





Linux中用户态和内核态定义了若干定长类型, 以32位无符号整数为例:





u_int32_t (BSD类型,目前netfilter中就使用这种类型)





用户态定义位于sys/types.h





在内核态见头文件include/linux/types.h





typedef __u32 u_int32_t;





uint32_t (C99类型, 内核态和用户态都能使用的类型,可移植性更好)





在用户态中见头文件/usr/include/stdint.h





在内核态见头文件include/linux/types.h





typedef __u32 uint32_t;











u32





typedef unsigned int u32;





include/asm-i386/types.h





只能在内核态使用











__u32 (Linux严格类型,内核中应该使用这种类型)





typedef unsigned int __u32;





include/asm-i386/types.h





也可以在用户态使用











unsigned long





unsigned int





标准C语言整数类型, 架构相关













----轉自周知远的博客













總結來說,推薦使用 uintxx_t 系列的C99 type.





只要include 即可。




















星期四, 5月 17, 2007

[HowTo] FreeBSD console framebuffer

First thing we have to do is add VESA and SC_PIXEL_MODE to the kernel and rebuild. You should always cvsup and rebuild your kernel and world to the latest available. However, don't try to 'optimize' the BSD kernel. It is already well optimized. If there is an option, like this, that you need to have, then go for it. We need to open the kernel config file. I would recommend that you cvsup first so that you rebuild the latest world/kernel, but it's optional.
cvsup -h cvsup2.freebsd.org -g -L 2 /usr/share/examples/cvsup/standard-supfile
Obviously, you can use whichever cvsup server you want. You can install fastest_cvsup to fins what server is fastest for your location as well. If this is the first time you are cvsup-ing, it will take some time. When it completes, we will continue.
cp /usr/src/sys/i386/conf/GENERIC /usr/src/sys/i386/conf/GENERICVESA
Name it to whatever you want.
vi /usr/src/sys/i386/conf/GENERICVESA
You will see, a couple of lines down an "ident GENERIC" line. You can change this if you want. It will be the display of the kernel in uname.

Directly after that, you will start to see 'option xxxxx #Description' sections..

This is where we add our options:
options VESA
options SC_PIXEL_MODE

Save your changes and exit.

From here, you generally build the world, and the kernel, install the kernel, reboot to single-user mode, mergemaster, installworld, etc... but I'm going to skip the buildworld because it will eat up a lot of time, and we can do it after the kernel.
cd /usr/src
make buildkernel KERNCONF=GENERICVESA
make installkernel KERNCONF=GENERICVESA
reboot
Now, you won't get the resolution just yet, we're not quite done. Boot back up and do the following:
kldload vesa
vidcontrol -i mode | less
You should see a punch of different modes. Scroll through and find one you'd like. For me, 1024x768x24 is the size I want. The first column shows the mode number, mine being 280.

Choose the one you want and try:
vidcontrol MODE_xxx
Substituting "xxx" for the number of the mode you want. The screen will go bank for a second, then it should come back with the prompt. If it cannot handle the resolution you specified, it should return with an error.

If it works, GREAT! Now we can add this to /etc/rc.conf to load on boot-up. However, we must make sure we load vesa on boot-up as well.
vi /boot/loader.conf
add the line :
vesa_load="NO"
change it to "YES" (maintaining caps)

Save, and exit.
vi /etc/rc.conf
and add to the end:
allscreens_flags="MODE_xxx"