Saturday, September 27, 2008

体验成都的长途客运服务

第一次来成都,就觉得这个城市还不错. 绿化挺多, 城市也还比较整结. 至少比长沙还是要好些. 前几天从成都去了趟绵阳.又体验到一次成都的好. 我是在昭觉寺坐的车. 到绵阳的车次很密集,不用怎么候车. 进站后,每台车的乘务员站在车前等候乘客. 并且乘务员统一着装. 这个我在其它长途车站没有看到过. 一下感觉这个服务品质肯定不一样. 上车后不一会车就开了. 乘务员先后用中文和英文说了一遍例行的欢迎话语. 我英语水平还没高到能去评价乘务员的英语水平,不过至少说明车站对乘务员的英语水平是有要求的. 然后乘务员给每人乘客发放一小瓶纯净水. 虽然这水可能是企业赞助的,但给人的感觉很好.
我第一次认识到:原来长途客运的服务也是可以做得这样好的.

Monday, September 15, 2008

address space resource

内核中有很多资源,但属于IO资源的有:
#define IORESOURCE_IO        0x00000100    /* Resource type */
#define IORESOURCE_MEM        0x00000200
#define IORESOURCE_IRQ        0x00000400
#define IORESOURCE_DMA        0x00000800

本文我主要研究IORESOURCE_IO IORESOURCE_MEM,及地址空间的管理,涉及的文件只有kernel/resource.c.
这两种资源本质上都是一段地址空间. 只是类型不一样
IORESOURCE_IO 指的是IO地址空间,这个空间从kernel编程上来看,只能通过专门的接口函数才能访问.硬件层面上,cpu需要用特殊指令才能访问或需要用特殊访问方 式才能访问,不能直接用指针来寻址.在PC机上,其指的就是PCI/CPU IO address space.在嵌入式中,基本上没有io address space.
IORESOURCE_MEM 指的是属于外设或者用于和设备通讯的支持直接寻址的地址空间.PC机上,主板上北桥上连的内存都是交给kernel直接管理,或者都是用于软件执行,所以 这部分内存不属于IORESOURCE_MEM, IORESOURCE_MEM主要是指PCI设备的 memory address space. 但在嵌入式上, 主板上的sdram一般是设备与cpu共享的. 故交给kernel直接管理的内存只是一部分.余下的内存以及寄存器空间都作为IORESOURCE_MEM来管理.

只所以需要管理,是 因为像PCI总路线设备的这些地址空间是设备向系统申请的,故是可配置的,并且设备并身可能热插拨或更换,故其变成一种可分配的资源. 故内核用算法来管理分配与释放操作,防止冲突和便于查询维护.但实际PC中,BIOS一般会做分配操作,内核需要是把分配结果添加进来,故提供了注册(或 者叫做添加)接口. 在嵌入式系统中,外设的地址也通常是固定的,只需要添加即可.

这两种资源,内核采用同样的管理算法--二叉树.相当于内核维护两个独立的二叉树. 按地址基地址与地址长度范围作为管理数据.可以添加,分配,释放节点.分配过程中可以避
免空间冲突,添加时可以识别空间冲突.根节点在kernel/resource.c中以全局变量方式定义.根节点用于限制地址空间的范围.

主要接口:
int insert_resource(struct resource *parent, struct resource *new)
int adjust_resource(struct resource *res, unsigned long start, unsigned long size)
int allocate_resource(struct resource *root, struct resource *new,
              unsigned long size,
              unsigned long min, unsigned long max,
              unsigned long align,
              void (*alignf)(void *, struct resource *,
                     unsigned long, unsigned long),
              void *alignf_data)
int release_resource(struct resource *old)
int request_resource(struct resource *root, struct resource *new)

上面的接口对上述4种资源类型都有效,对于IORESOURCE_IO 和 IORESOURCE_MEM这两种资源,使用这两个接口更为方便
request_region(start,n,name)
release_region(start,n)
        io space
request_mem_region(start,n,name)
release_mem_region(start,n)
        mem space

在 /proc 文件系统中,ioports和iomem分别显示系统当前这两种资源.


嵌入式设备的外设一般先作为platform device添加到platform bus上,其主要目的就是向系统注册资源,在platform_add_devices时做,
如:
/* Watchdog timer parameters */
static struct resource wdt_resource[] = {
    /* Watchdog timer only needs a register address */
    [0] = {
        .start = 0xFFC00008,
        .end = 0xFFC00010,
        .flags = IORESOURCE_MEM,
    }
};

struct platform_device wdt_device = {
    .name = "wdt",
    .id = -1,
    .num_resources = ARRAY_SIZE(wdt_resource),
    .resource = wdt_resource,
};
platform_add_devices(wdt_device,1);


故如已知设备的物理地址,并不一定需要request_mem_region,因为这个操作并没有涉及到任何硬件,与软件访问也没有任何关系..但一般还是推荐做.

I/O port 访问流程( 不用mem模拟方式):
request_region()   #在设备驱动模块加载或opn() 函数中进行,物理i/o port地址由pci bios模块分配
inb(),outb()等     #在设备驱动初始化,write(),red(),ioctl() 等函数中进行
relase_region      #在设备驱动模块卸载或release() 函数中进行

I/O port 访问流程( 用mem模拟方式):
request_region()
ioport_map         #在设备驱动模块加载或opn() 函数中进行,物理i/o port地址由pci bios模块分配
ioread8,iowrite8等 #在设备驱动初始化,write(),red(),ioctl() 等函数中进行
ioport_unmap()
relase_region      #在设备驱动模块卸载或release() 函数中进行


request_mem_region
ioremap         #在设备驱动模块加载或opn() 函数中进行,物理i/o port地址由pci bios模块分配
ioread8,iowrite8等 #在设备驱动初始化,write(),red(),ioctl() 等函数中进行
iounmap()
relase_region      #在设备驱动模块卸载或release() 函数中进行

内核如何识别root参数所指定的根文件系统设备

把内核的sysfs配置选择去掉后,发现无法mount根文件系统了. 于是,看内核是怎么识别root参数的,以及其与sysfs的关系.
 root 参数的处理在是do_mount.c的prepare_namespace函数里. 基本原理为:先munt devfs到/dev目录,然后根据root参数中指定的设备文件名字,从devfs中找到设备文件对应的dev对象,这样就可以开始mount操作了. 不过devfs文件系统已被废弃了. 相应的功能由sysfs取代. 逻辑差不多.
  另外 /dev/nfs 并不是实际设备文件,只是根代表文件系统为nfs文件系统. 故处理逻辑中不会用到devfs或sysfs. 所以去掉 sysfs 后,内核仍然能mount 上nfs根文件系统,而无法mount上flash mtd partition上的根文件系统.

(移动)硬盘安装fedora9

拿着公司的笔记本回来装fedora9,发现光驱不能用. 故重新温习了一下硬盘安装linux的操作.
以下为笔记:

是内置硬盘,还是usb移动硬盘,方法都是一样的. 故这里不加区分.

基本原理: 开机BIOS加载硬盘上的引导程序grub,gurb从硬盘上引导一个kernel和简单安装程序. 简单安装程序启动后,此时有足够的设备驱动, 再由你来选择具体安装方式: 硬盘安装(ISO)或网络安装(NFS),并进行相应的配置.

上 面提到的安装程序的kernek和简单安装程序都在ISO文件的isolinux目录下,分别叫vmlinuz和initrd.img. 我们将其解出到硬盘的某个分区上(gurb不支持NTFS文件系统). 简单安装程序不支持NTFS文件系统,所以ISO文件要存放在非NTFS分区上.

因此第一步要安装grub.由于gurb要由 BIOS引导,故gurb要安装在任何可启动的磁盘驱动器上. 如你的内置硬盘,或USB存储介质(如BIOS支持的话). 如果电脑的内置硬盘上已经安装有windows,可以在windows里进行安装gurb. 下载WINGURB,选择grub-install,设备选你的内置硬盘即可. 由于grub支持命令行编辑启动,所以无需配置,只要安装上就行. 重启后即进入到grub启动界面,按c进入命令行模式, 用root命令设定vmlinuxz以及initrd.img所在的分区为root分区. 接着用kernel命令和initrd分别选定 vmlinuxz和initrd.img. 最后输入 boot 即可启动. 配置完语言和键盘后,即选择安装方式,选硬盘安装并且指定好ISO所在分区和目录即开始常规的安装过程.

chroot初探

最初使用chroot这个命令是在 fedora 系列的救援模式下,实现根文件系统由光盘上的文件系统切换到本地硬盘上的文件系统. 最近由于开发中要用到这个命令,故好好看了看文档,加深一下了解.

  这个命令的功能描述为:Run a command with a different root directory. 即在/目录理解成其它目录的环境下运行一个命令. 而我以前将其错误的理解成整个应用环境的功换. chroot下应用执行环境与原来的环境的差别只是/目录的实际物理路径不一样(当然会造成同样的路径所访问到的实际文件不一样)

 不过实际使用中,一般都是这样用chroot:
chroot 目录
 这 种用法后面没有跟一个命令作为参数,chroot会默认执行SHELL环境变量所保存的值作为命令来执行. 由于SHELL这个程序运行起来后不会退出,且会在终端下给出命令提示符,所以整个个命令执行起来后,即陷入,同时出现新shell的提示符,给人的感觉 是切换到新的用户环境. 由于新的shell会重新载入一些环境变量以及初始化脚本,故新环境下坏境变量与原来的环境变量还是有一些差别的.

要测试的话:
新建一个目录,把/bin以及/lib目录拷贝到新目录下,然后就可以chroot到新目录,输入exit即回到原来的环境.

openoffices tip

以前一直习惯于用文本文件来作笔记. 回过头来看这些笔记的时候发现表现力还是不够,或者不够清晰. 于是开始转到openoffice来. 摸索了一阵后,终于可以应付简单的排版了. 以下为备忘:

页面横向纵向设置:
在 Format --> Page 菜单里,  对应英文为Orientation:  Portrait(纵向)  Landscape(横向)

linux用电驴

amule 和 emule 的区别在于 2.1.3的amule不支持upnp端口映射. 故需要要路由器器上去作固定端口映射,速度才上得去.

安装amule:
yum install amule.

所需要做的配置:
1,更新服务器列表
http://www.emule.org.cn/server.met
2,更新 kad 网络
http://www.emule-inside.net/nodes.dat
3,更新用户名前缀
[CHN][VeryCD] 否则连不上 VeryCD 的这个服务器(no1.eserver.emule.org.cn)这 2 个服务器对于国内
用户是相当不错的选择。



浏览器关联:
在地址栏输入 about:config
新建"布尔"
名称为:network.protocol-handler.external.ed2k
值为:true
新建"字符串"
名称为:network.protocol-handler.app.ed2k
值为:/usr/bin/ed2k

shell脚本的路径问题

从网上找到如何从得到shell script的绝对路径的方法:

#! /bin/bash
echo "Path to $(basename $0) is $(readlink -f $0)"

但这种方法只适以子shell方式执行的脚本,不适用于在当前shell中执行的脚本.

难道就没有方法了吗? 

Latex初探

    前段时间要给公司新员工培训linux方面的知识,故使用openoffice来做. 不知道是不是我的版本有问题还是什么原因,设置格式什么的不太好用.当然对于微软的office,我也不太熟悉.

    偶然间在水木上进去到latex的版块,简单了解一下后也就有了想学的冲动. 立刻找资料.但估计这个东西和emacs一样,学习曲线都会是十分陡的. 所以学习笔记先就不在这里记了. 等以后感觉学到某个阶段,再把整理好的笔记补上.

tor

firefox 使用 tor :

1. yum install tor
2. install foxyproxy add-on in firefox
2. restart system or start tor manually
3. configure the autoproxy(firefox add-on) to using tor with specify URL.
4. enjory

yum使用代理

添加 一行:proxy=http://x.x.x.x:x在/etc/yum.conf.

双系统共享邮件

由于工作需要使用linux, 而部分工作又离不开 win(主要是写烦人的文档. ). 故经常两个系统切换.  这就造成 两个问题: 邮件在一个系统下
收了,无法在另一个系统下访问到。 另外一个就是两个系统下的浏览器的bookmark需要手动去同步.

今天终于试验了一下这两者都使用跨平台的软件,分别是firefox和thunderbird. 并且把储存配置文件和数据的目录(profile)指向硬盘的同一个位置.

这里要注意两个平台下的这两个软件的版本最好一致,否则启动时老是要检果插件版本等工作,影响启动速度.

修改firefox profile 路径的方法:
Mozilla Firefox stores all your personal settings, such as bookmarks, passwords and extensions, in a profile. The profile is stored on your hard drive in a profile folder

Move an existing profile or restore a backed up profile

It's possible to move the location of a profile folder. This could be useful if you have a backed up profile folder somewhere
on your hard drive and want to tell Firefox to use that as your profile. This section explains how to do this.

   1. Shut down Firefox completely (File > Exit).
   2. Move the profile folder to the desired location. For example, on Windows XP, move the profile from C:\Documents and Settings\[username]\Application Data\Mozilla\Firefox\Profiles\xxxxxxxx.default to D:\Stuff\MyProfile. If you are reading these instructions because you want to restore a previously backed up profile, this step isn't necessary. Just note the current location of the profile you want to restore.
   3. Open up profiles.ini in a text editor. The file is located in the application data folder for Firefox:
          * On Windows Vista/XP/2000, the path is %AppData%\Mozilla\Firefox\
          * On Windows 95/98/Me, the path is usually C:\WINDOWS\Application Data\Mozilla\Firefox\
          * On Linux, the path is ~/.mozilla/firefox/
          * On Mac OS X, the path is ~/Library/Application Support/Firefox/
   4. In profiles.ini, locate the entry for the profile you've just moved. Change the Path= line to the new location. If you are using a non-relative pathname, the direction of the slashes may be relevant (this is true for Windows XP).
   5. Change IsRelative=1 to IsRelative=0.
   6. Save profiles.ini and restart Firefox.

修改tunderbird profile 的方法差不多.

用 firefox 保存网页中的 flash

http://labnol.blogspot.com./2005/11/save-flash-from-firefox-and-ie.html 里介绍可以这样做:

1. Saving Flash files from Firefox

Firefox for Newbies
a. Click Tools - Page Info
b. Click the Media Tab on the Page Info Windows
c. The media tab has a complete list (with preview) of Images, CSS Files and Shockwave Flash files that were downloaded by the Firefox browser while rendering (loading) the page.
d. Scroll down the list and locate the swf file.
e. Click the "Save As" button. Select some directory on your hard drive and save the file (No need for a third-party plug-in)

Firefox for Geeks and Power Users
a. Type about:blank in the Firefox address bar
b. Now click List cache entries or directly type about:cache?device=disk (Disk cache device)
c. Press Ctrl+F and try to location the flash file by typing some part of website URL or the flash file name or just .swf. After some hit and trial, you should be able to locate the swf file URL
d. Click the SWF URL to open the Cache Entry Information page. Right click on the link and choose "Save link as"

不过Firefox for Newbies 的方法对于我所要的保存的Flash 不管用. 而for Power Users 的方法好像有点麻烦. 有个插件可以帮忙:
cacheviewer

安装完成后,在Firefox浏览器中,点击 工具->CacheViewer,打开下面的窗口,在"搜索"(search)中填入要找的flash的文件名,双击保存就可以了。

thread

A thread may be created as a joinable thread (the default) or as a detached thread. A joinable thread, like a process, is not automatically cleaned up by GNU/Linux when it terminates. Instead, the thread's exit state hangs around in the system (kind of like a zombie process) until another thread calls pthread_join to obtain its return value. Only then are its resources released. A detached thread, in contrast, is cleaned up automatically when it terminates. Because a detached thread is immediately cleaned up, another thread may not synchronize on its completion by using pthread_join or obtain its return value.

When create thread with pthread_create, the attr argument can also be NULL, in which case default attributes are used: the created thread is joinable (not detached) and has an ordinary (not realtime) scheduling policy.

关于linux 实时性的 好文章
http://blog.tom.com/blog/read.php?bloggerid=993876&blogid=57349

compile and debug directfb

First is something about my develpment environment:
[root@localhost bin]# uname -a
Linux localhost.localdomain 2.6.20-1.2952.fc6 #1 SMP Wed May 16 18:59:18 EDT 2007 i686 i686 i386 GNU/Linux
[root@localhost bin]# rpm -qa | grep gcc
libgcc-4.1.1-30
gcc-4.1.1-30
gcc-gfortran-4.1.1-30
gcc-c++-4.1.1-30

1. Enable Frame buffer device dirver in your machine.

DirectFB version: DirectFB-1.0.0 DirectFB-examples-1.0.0
2. DirectFB:
./configure --prefix=/home/dybbuk/study/DirectFB_install/ --enable-x11 --enable-debug
make
make install

3. DirectFB-examples
./configure --prefix=/home/dybbuk/study/DirectFB_install/ DIRECTFB_CFLAGS=-I/home/dybbuk/study/DirectFB_install/include/directfb/ DIRECTFB_LIBS="-L/home/dybbuk/study/DirectFB_install/lib/ -ldirectfb"
make
make install

Test(under char mode):
export $LD_LIBRARY_PATH=/home/dybbuk/study/DirectFB_install/lib/
/home/dybbuk/study/DirectFB_install/bin/df_window

4. deubg:
add a line "system=x11"  in  the /etc/directfbrc file. 
debug directfb application under X.

For more information see the maillist below:


A copy-paste regarding X method. But I don't know a way without X, and with one machine. If u come to know, plz post it :-)
-----------

Use X

Just for the sake of development, DirectFB actually provides an X backend. In that mode, an X window is the directfb screen, and all directfb display goes to that X window. That is convenient, because
  • We can simultaneously work with whatever other X applications we want
  • Much easier to debug,
  • In situations like crashing or hanging up, you can just close the window, or in the worst case, just killall -9 program-name

Using the X backend

If you did not build directfb with --enable-x11 option, you need to rebuild it with that option(the option is given to configure script). Then, in the /etc/directfbrc file, you need to add a new line: system=x11

Then you can run the same directfb application from X

For performance analysis, and final testing, I would recommend using virtual console, and not X, because thats the way directfb will finally work...



Colin Newell wrote:
What is the best way to run a debugger to debug a directfb program?

One choice is to open an xterm into the machine supporting directfb, and
run gdb in the xterm. If you can see the screen of the directfb machine,
and the Xserver's screen you can efficiently debug.

What if you only have the directfb machine to work on?

If I run gdb on a directfb program directly on the machine with
directfb, then as soon as directfb starts up, gdb loses control of the
keyboard and screen (and then I need to actually kill the program via
an xterm). Is there a clever way to allow use of gdb directly on a
machine running directfb?

Any ideas appreciated.

Regards
Colin Newell

_______________________________________________
directfb-users mailing list
directfb-users@directfb.org
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-users



mplayer on frame buffer

The mplayer rpm package form livna is compiled without frame buffer output support( 'mplayer -vo help' for a list of output drivers supported).

So recompile mplayer is needed.
1. enable frame buffer device driver in kernel
For FC6, only append vga=791 to kernel parameter when start kernel can enable frame buffer device driver.
run 'fbset -i' to see some infomation about current frame buffer.
[dybbuk@localhost mplayer_fc6]$ cat /proc/cmdline
ro root=LABEL=/ rhgb quiet vga=791

[dybbuk@localhost mplayer_fc6]$ /usr/sbin/fbset -i
mode "1024x768-76"
    # D: 78.653 MHz, H: 59.949 kHz, V: 75.694 Hz
    geometry 1024 768 1024 768 16
    timings 12714 128 32 16 4 128 4
    rgba 5/11,6/5,5/0,0/0
endmode

Frame buffer device information:
    Name        : VESA VGA
    Address     : 0xc0000000
    Size        : 3145728
    Type        : PACKED PIXELS
    Visual      : TRUECOLOR
    XPanStep    : 0
    YPanStep    : 0
    YWrapStep   : 0
    LineLength  : 2048
    Accelerator : No


2. recompile mplayer
Get lattest developent version from the mplayer svn repository. when configure the source tree, check fbdev list in the enabled video output drivers.

3. test
./mplayer -vo fbdev -vf scale=1024:768 ../../The_Code-Linux.avi

Using Directfb:
   
1. Install directfb and driverfb-dev package
2. modify /etc/fb.modes, add the current frame buffer mode as the first mode.
3. reconfigure and recompile mplayer. make sure directfb list in the enabled video output drivers
4. ./mplayer -vo directfb -vf format=bgr16 ../../The_Code-Linux.avi
(without specify bgr16 format, the picture will all messed up with a lot of green. my graphic chipset is intel 945GM ).

RCS 使用初探

借了本书<<LINUX SERVER HACKS>>,以下部分就当做读书笔记
RCS 的作用管理系统文件,并保存修订历史(ps: 在服务器的管理上应该特别有用)

1. 建立RCS仓库
    由于RCS将所有修订版本保存在当前目录下的RCS目录中,故要启动RCS仓库,只需创建该目录即可
    mkdir RCS

2. 加入文件
    仓库建立好了,就可以用了。现在把当前目录下要管理的文件加入到仓库中来
    ci -i Filename
    这条命令会把文件移入到RCS下,并建立这个文件的第一个版本1.1。命令会要你输入初始化说明(以C-d结束). 

3. 登出文件-得到最新版本
    第二条命令把文件移到RCS下了,当前目录就没有这个文件了。这可不行,那就从RCS中登出文件,即得到最新版本。
    co Filename

4. 登出并锁定文件
    如果登出的目的是为了要编辑,那在登出时加锁,以妨其它用户在这段时间更新文件
    co -l Filename

5. 登入并解锁文件
    编辑完成,更新版本吧
    ci -u Filename
    命令会要你加入修订说明。

6. 版本比较
    编辑完成了,想回顾一下自己做了哪些修改
    rcsdiff httpd.conf
    这条命令也就是拿RCS中的版本和当前目录下的版本作比较

更多:
    checkout时加参数-rn.n指定得到n.n版本
    rcsdiff -rn.n -rn.n 比较两个指定版本
   
关于rcs2log的示例在fc5上有错误输出,不知道为什么
sort: invalid option -- 4
Try `sort --help' for more information.
其用法如下:
    rcs2log -v Filename 查看文件的各个版本信息
    rcs2log Filename 查看文件修订记录
   




chipset

chipset
    x86体系上,其是南桥和北桥芯片的构成的,一种chipset即是一组特定的南桥和北桥的集合. 对于移动平台和x86嵌入式平台. 南桥和北桥芯片可能合到一起成为一块芯片. 

硬件反向工程

硬件反向工程(Reverse Engineering RE)


包括以下几种形式:

  • Product tear-downs identify the product, package, internal boards, and components

  • System level analysis analyse operations, signal paths, and interconnections

  • Circuit extraction delayer to transistor level, then extract interconnections and components to create schematics

  • Process analysis examine the structure and materials to see how it is manufactured, and what it is made of.

第一种即常见的拆解和pcb抄板. 第二种则主要是借助逻辑分析仪来分析硬件的工作时序或协议. 第三种则主要是得到集成电路的原理图或硬件逻辑. 第四种则是深入分析晶体管的制造工艺以及进行失效分析等.


硬件反向工程领域知名公司: 国外为ChipWorksSemiconductor Insights(SI),国内有上海圣景微电子和北京芯愿景. (行业介绍可以看:IIC-China:中国两大反向工程公司相见言欢,谜底何在)


集成电路的反向工程领域(相关介绍参见:正确实施反向工程,有利于提高芯片设计技术),通常的操作有:

常的操作有:

  1. 封装去除(decapsulate/decap):

    用酸将封装去除以便提取晶粒

  2. 层次去除(delayer):

    除去已分析的层或无关层

  3. 芯片染色:

    为了区分器件类型,需要对衬底进行染色

  4. 芯片拍照

    用光学显微镜或电子显微镜对芯片进行拍照.

  5. 电路提取

    借助自动化软件对照片进行电路分析提取



封装去除的一些照片:



完全decap以后晶粒(die)放大图:

其中die所在空腔叫 cavity. die边缘连出的线上叫banding wire. die所依附的底座叫substrate. Substrate四周的片状条叫lead frame. Lead frame连到封装上的pin(这点图上没有).



(AMD AM29X305ADC MCU 图片来源于http://diephotos.blogspot.com/,该页面有更多类似精美的图片)



反向工程的全过程介绍: Safenet iKey 2032 In-depth Look Inside (该网站上还有很多类似的反射工程例子)



有关Intel's Prescott die 介绍:
见http://www.chip-architect.com/news/2003_04_20_Looking_at_Intels_Prescott_part2.html


查找资料当中遇到其它一些单词:

Epoxy 环氧树脂,在以前一般是把die直接附着在pcb,这时用epoxydie保护起来. 计算器pcb板上的那团黑色的物质就是(小时候我一直没想明白那里面包着的是什么东西).

Wafer 晶圆

CFI


    CFI 由 jesd68 标准定义. 其标定了设备的 Query interface. 用于得到设备所支持的命令集和参数. 其并没有定义任何命令集.  从Query interface得到的信息有一个16-bit ID code(Algorithm Command Set and Control Interface ID Code),其取值和含义在JEDEC PUBLICATION: jep137b 中规定.
如:
    0001     Intel/Sharp Extended Command Set
    0002     AMD/Fujitsu Standard Command Set
    0020     ST Advanced Architecture   (这个在jep137b中没有列出)

软核,固核,硬核


IP(Intellectual Property)就是常说的知识产权。美国Dataquest咨询公司将半导体产业的IP定义为用于 ASIC、ASSP和PLD等当中,并且是预先设计好的电路模块。IP核模块有行为(Behavior)、结构(Structure)和物理 (Physical)三级不同程度的设计,对应描述功能行为的不同分为三类,即软核(Soft IP Core)、完成结构描述的固核(Firm IP Core)和基于物理描述并经过工艺验证的硬核(Hard IP Core)。

什么是软核?
IP软核通常是用 HDL文本形式提交给用户,它经过RTL级设计优化和功能验证,但其中不含有任何具体的物理信息。据此,用户可以综合出正确的门电路级设计网表,并可以进 行后续的结构设计,具有很大的灵活性,借助于EDA综合工具可以很容易地与其他外部逻辑电路合成一体,根据各种不同半导体工艺,设计成具有不同性能的器 件。软IP内核也称为虚拟组件(VC-Virtual Component)。
Soft Core
An IP Core that is delivered in the form of a hardware description language or schematic diagram.

什么是硬核?
IP硬核是基于半导体工艺的物理设计,已有固定的拓扑布局和具体工艺,并已经过工艺验证,具有可保证的性能。其提供给用户的形式是电路物理结构掩模版图和全套工艺文件,是可以拿来就用的全套技术。
Hard Core
An IP Core that is delivered in the form of a mask set (i.e. a graphical description of the features
and connections in an integrated circuit).

什么是固核?
IP固核的设计程度则是介于软核和硬核之间,除了完成软核所有的设计外,还完成了门级电路综合和时序仿真等设计环节。一般以门级电路网表的形式提供给用户。
Firm Core
An IP Core that is delivered in a way that allows conversion into an integrated circuit design, but
does not allow the design to be easily reverse engineered. It is analogous to a binary or object
file in the field of computer software design.

dot emacs

今天双给我的 .emacs 添加了一点新的内容

;; 向前删除一个单词,相应的把默认绑定的 Kill-region 换到其它键
(global-set-key "\C-w" 'backward-kill-word)
(global-set-key "\C-x\C-k" 'kill-region)
(global-set-key "\C-c\C-k" 'kill-region)

(global-set-key (kbd "M-g") 'goto-line)

;; 当文件被修改后相应文件buffer自动刷新
(global-auto-revert-mode 1)

;; Changes all yes/no questions to y/n type
(defalias 'yes-or-no-p 'y-or-n-p)

;; Scroll down with the cursor,move down the buffer one line at a time, instead of in larger amounts.
(setq scroll-step 1)

;; do not make *~ backup files 实际上我很少用到这个备份文件
(setq make-backup-files nil)


;; displays the time in the status bar
(display-time)


不过没有两个问题没有解决:
1. 第一次woman时,其有个 building completion list of all manual topics 的过程,这个过程还是要耗点时间.有没有办法去掉这个过程?

2. woman一个词时,可能会有很多区的manual命中,有没有可能根据当前buffer mode来自动选择一个区.如
pritnf存在于这几个区:
/usr/share/man/man1/printf.1.gz /usr/share/man/man1p/printf.1p.gz
/usr/share/man/man3/printf.3.gz /usr/share/man/man3p/printf.3p.gz.
当我在c-mode下使用woman printf时,则自动选择man3.

3. dired 模式下,按C可以选择拷贝当前选中的文件夹到其它目录,有没有操作可以拷贝一个其它目录到当前目录.

4. 怎么设置 M-x gdb 时是新开一个frame? 因为我想达到一个窗口编辑编译,一个窗口调试的效果..

Install Emacs23

Get the latest version of emacs:


cvs -z3 -d:pserver:anonymous@cvs.savannah.gnu.org:/sources/emacs co -r emacs-unicode-2 emacs


Compile:

$ mkdir output

$ cd output

$ ../emacs/configure --enable-font-backend --with-xft --with-freetype --with-gtk

$ make bootstrap

$ make

then you can run emacs under src directory.

FC6上使用emacs23可以得到以下好处:
1. 中文不会出现方框
2. minibuffer里显示中文目录和文件时不会乱码
3. 字体大小调整速度变快

mpeg ts stream type

mpeg PMT 的 stream type汇总:
H.222总是在修订,增加最新的类型. 以下来源于 H.222.0 (2006) Amendment 2

Value Description
0x00 ITU-T | ISO/IEC Reserved
0x01 ISO/IEC 11172-2 Video
0x02 ITU-T Rec. H.262 | ISO/IEC 13818-2 Video or ISO/IEC 11172-2 constrained parameter video stream
0x03 ISO/IEC 11172-3 Audio
0x04 ISO/IEC 13818-3 Audio
0x05 ITU-T Rec. H.222.0 | ISO/IEC 13818-1 private_sections
0x06 ITU-T Rec. H.222.0 | ISO/IEC 13818-1 PES packets containing private data
0x07 ISO/IEC 13522 MHEG
0x08 ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Annex A DSM-CC
0x09 ITU-T Rec. H.222.1
0x0A ISO/IEC 13818-6 type A
0x0B ISO/IEC 13818-6 type B
0x0C ISO/IEC 13818-6 type C
0x0D ISO/IEC 13818-6 type D
0x0E ITU-T Rec. H.222.0 | ISO/IEC 13818-1 auxiliary
0x0F ISO/IEC 13818-7 Audio with ADTS transport syntax
0x10 ISO/IEC 14496-2 Visual
0x11 ISO/IEC 14496-3 Audio with the LATM transport syntax as defined in ISO/IEC 14496-3/Amd.1
0x12 ISO/IEC 14496-1 SL-packetized stream or FlexMux stream carried in PES packets
0x13 ISO/IEC 14496-1 SL-packetized stream or FlexMux stream carried in ISO/IEC 14496_sections
0x14 ISO/IEC 13818-6 Synchronized Download Protocol
0x15 Metadata carried in PES packets
0x16 Metadata carried in metadata_sections
0x17 Metadata carried in ISO/IEC 13818-6 Data Carousel
0x18 Metadata carried in ISO/IEC 13818-6 Object Carousel
0x19 Metadata carried in ISO/IEC 13818-6 Synchronized Download Protocol
0x1A IPMP stream (defined in ISO/IEC 13818-11, MPEG-2 IPMP)
0x1B AVC video stream as defined in ITU-T Rec. H.264 | ISO/IEC 14496-10 Video
0x1C ISO/IEC 14496-3 Audio, without using any additional transport syntax, such as DST, ALS and SLS
0x1D ISO/IEC 14496-17 Text
0x1E Auxiliary video stream as defined in ISO/IEC 23002-3
0x1F-0x7E ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Reserved
0x7F IPMP stream
0x80-0xFF User Private

静音

(此文为个人理解,有错误请指出)
硬静音: 通过控制电路,使音频信号一下消失的操作,一般实现为直接断开继电器触点或接地,扬声器一般会发出冲击声.波形如下所示:


软静音: 当要静音时,使音频信号交流分量幅度逐渐归零的过程,可以避免硬静音时的冲击声.波形如下所示:

Video Level

电平(level)

电平是指某一个测量点的电压,电流,功率与基准值的功率,电压,电流的比较值. 常见的是一般是电压电平. 如模拟视频中以差值来表示电平,消隐电平为0v. 即以消隐电平的电压来作为基准值来度量其它电压的相对电压,0.7v的黑电平(实际黑电平的电压为消隐电平的电压加上黑电平的值). 在模拟音频中,比较值以分贝来描述. 这样表示的电平其单位以dbx表示(x为实际物理单位,dbv). 这在模拟音频当中用的比较多. 实际使用时,还有更多的表示方式.但只要记住电平是相对值,谈电平,一定要从语境中找基准值,即电平定义成0的量值.

video level.
在标准里经常使用IRE(Institute of Radio Engineers )来表示video level..


(上图注解: blanking level 中文标准里叫做消隐电平. Black levelblanking level 间的电平叫做setup level. 此图中IRE的定义为:The blanking level refers to 0 IRE and the white level refers to +100 IRE . 在一些资料中也有以sync level作为 0 IRE. )


IRE其实就是个相对百分比量值. 因此在中文标准里IRE数值是带百分号的. GB3174-1995

在各个标准里:

SJ-T 11329-2006 数字电视接收设备接口规范第3部分:复合视频信号接口.pdf

SJ-T 11330-2006 数字电视接收设备接口规范 第4部分:亮度、色度分离视频信号接口.pdf

SJ-T 11333-2006 数字电视接收设备接口规范 第7部分:YPBPR模拟分量视频信号接口

都没对视频信号中的电压作任何限定.


为什么视频信号的电压不重要?

因为视频输入电路一般会隔直钳位电路.

视频分量标准

1. 同步信号出现在哪个分量上

For consumer products, composite sync is present on only the Y channel. For pro-video applications, composite sync is present on all three channels.

2. 同步方式

Tri-level synchro

Bi-level synchro

3.分量国际标准间的基本区别:

* HD formats (Tri-level synchro)

SMPTE274M / EIA-770.3 (1920 x 1080i) @ 60Hz

SMPTE274M / EIA-770.3 (1920 x 1080i) @ 50Hz

SMPTE295M / EIA-770.3 (1920 x 1080i) @ 50Hz

SMPTE296M / EIA-770.3 (1280 x 720p) @ 60Hz

SMPTE296M / EIA-770.3 (1280 x 720p) @ 50Hz

* HD formats (Bi-level synchro)

AS4933 (1280 x 1152i) @ 50Hz

AS4933 (1920 x 1080i) @ 50Hz

* SD progressive formats (ED) (Bi-level synchro)

SMPTE293M / EIA-770.2 (720 x 480p) @ 59.94Hz

ITU-R BT1358 / EIA 770.2 (720 x 576P) @ 50Hz

5. 中国的分量标准

SJ-T 11333-2006 数字电视接收设备接口规范 7部分:YPBPR模拟分量视频信号接口

特点:

1. 其所规定可以支持的视频扫描格式

720X480i@60

720X576i@50

720X576p@50

1920X1080i@50(行频28.125)

1920X1080i@60

1280X720p@60

1280X1080i@50(行频31.25)

2. 同步只出现在Y信号上

3. 标清采用Bi-level synchro, 高清采用 Tri-level synchro

aspect ratio

电视机一般有种:4:3和16:9的.即电视机的aspect ratio.
这个含义是指的是电视机的物理尺寸(或满屏时图像的)的宽高比.
4 :3 = 1.333
16:9 = 1.778
故16:9的电视机要比4:3的电视机看起来更宽一些,16:9的电视机也叫宽屏电视机.

而数据源对图像的大小的描述除了一般讲的图片的宽高外,还有pixel aspect ratio.
图片的宽高一般以pixel为单位. 在pc上,pixel aspect ratio通常是1:1. 则图片宽高像素数的比即是图片正常显示出的来的宽高比.

而实际上在video中,除了描述image的宽高像素量之外(如 720:576),还会描述image的aspect ratio(如4:3或16:9).
4:3的image和 16:9 的image,其pixel aspect ratio 是不一样的

4.3:
x1= (4/3)/(720/576) = 1.066
16:9:
x2=(16/9)/(720/576) = 1.422
x1:x2 = 3/4.

所以16:9 的图看起来是比 4:3的要宽一些. 因为每个像素要宽一些.

如果把 4:3的图直接当 16:9来理解或显示的话, 则图看起来被横向拉长而失真.
要不失真显示的话,必须对数据进行处理.
letter-box:
保持y轴解析度不变,模向按16:9重新采样,则采样数目不足720个,需要以黑色补足720个,所以在16:9屏幕上显示起来左右有黑边.
pan and scan
保持x轴解析度不变,纵向按16:9重新采样,则会多于576个. 一边做法是裁掉上下超出部分,保证采样个数为576个


pc业界图片和显示设备的pixel aspect ratio都是1. 则显示设备当工作在最佳分辨率这下时,其aspect ratio即为分辨率之比.


因此pc上的图放到电视机上显示需要重新采样. 同样电视节目在pc机上播放也需要重新采样. 例如4:3 PAL制电视节目在pc上播放,其正常显示窗口应该为768*576.


pixel aspect ratio:
D1/DV NTSC
(4:3)/(720/480) = 0.889
D1/DV NTSC 16:9
(16:9)/(720/480) = 1.185
D1/DV PAL
(4:3)/(720/576) = 1.066
D1/DV PAL 16:9
(16:9)/(720/576) = 1.422
(这些值和http://en.wikipedia.org/wiki/Pixel_aspect_ratio上的有些出入,不知为什么)

uclibc && nptl

不经意间发现自己使用的uclibc rpm包是带有nptl的. 于是上网查了一下这个nptl的含义.

具体可以看:
Linux threading models compared: LinuxThreads and NPTL
http://www.ibm.com/developerworks/linux/library/l-threading.html

glibc已经默认使用 NPTL. 而uclibc现在官方版本还是使用的linuxthread. 要使用nptl,则需要下载nptl分支:
svn://uclibc.org/branches/uClibc-nptl.

weak symbol

nm的manual里的说明:
When a  weak  defined symbol is linked with a normal defined symbol, the normal defined symbol is used with no error.  When a weak undefined symbol is linked and the symbol is not defined,  the  value of  the  symbol is determined in a system-specific manner without error.  On some systems, upper-case indicates that a default value has been specified.

网上其它有关的说明:
weak symbols can very well exist many or zero times. This will not cause any problem. If no symbol is found, a null one is provided. In case many symbols are found, the first one is taken and used by everybody.
(http://proj-gaudi.web.cern.ch/proj-gaudi/tricks/dynamic_cast.php)

测试程序:
说明:
  1. null为空,固打印了"not found null".
  2. strong函数的定义一处为weak,一处为strong,则链接器选用后者
  3. weak函数的定义两处都为weak,则链接器选用链接器所看到的第一个weak. (固更改链接命令o文件的位置即可得到不同的效果)
  4. 该测试只针对静态链接,对于动态链接效果怎么还末知
--------------------------------------------------
weak.c
--------------------------------------------------
extern void null() __attribute__((weak));
extern void strong() __attribute__((weak));
extern void weak() __attribute__((weak));

void strong()
{
    printf("false strong\n");
}

void weak()
{
    printf("first weak\n");
}

main()
{
    if(!null)
        printf("not found null \n");
    
    strong();
    weak();
}

--------------------------------------------------
strong.c
--------------------------------------------------
void strong()
{
    printf("true strong\n");
}

extern void weak() __attribute__((weak));
void weak()
{
    printf("second weak\n");
}

--------------------------------------------------
Makefile
--------------------------------------------------
.PHONY:clean

CFLAGS := -g -O0

%.o:%.c
    gcc $(CFLAGS) -o $@ -c $^
weak:  weak.o strong.o
#weak:   strong.o weak.o
    gcc $^ -o $@

weak.o: weak.c

strong.o: strong.c

clean:
    rm *.o

--------------------------------------------------
output:
--------------------------------------------------
[dybbuk@localhost tmp]$ ./weak
not found null
true strong
first weak
[dybbuk@localhost tmp]$ nm weak.o
00000028 T main
         w null
         U puts
00000000 W strong
00000014 W weak
[dybbuk@localhost tmp]$ nm strong.o
         U puts
00000000 T strong
00000014 W weak

Macros with a Variable Number of Arguments

Macros with a Variable Number of Arguments.
================================================

In ISO C99, a macro with a variable number of arguments can be defined.

example:
    #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)

this macro has two parameter:format and ..., as __VA_ARGS__ stands for ... . So the invocation of this macro shall have two arguments acording to ISO C.

So the statement below is invalid.
    debug ("A message");    //only one argument
and it should be:
    debug ("A message",);   //an empty argument

But under GUN C, it is valid.

In the above examples, the compiler would complain though since the expansion of the macro still has the extra comma after the format string. (a error)

To help solve this problem, CPP behaves specially for variable arguments used with the token paste operator, `##'.  If instead you write

    #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)

and if the variable arguments are omitted or empty, the `##' operator
causes the preprocessor to remove the comma before it.


And under GNU C, a more readabel way to refer variabel arguments.

    #define debug(format, args...) fprintf (stderr, format, args).


See gcc info section 5.14 'Macros with a Variable Number of Arguments' for more information.

test code:

#include <stdio.h>

#define DEVICE_NAME "test"
#define dprintk(fmt, ...) \
    do{ \
        if(1) printf(DEVICE_NAME ": " fmt, \
                 ## __VA_ARGS__); \
    }while(0)

#define dprintk1(fmt, ...) \
    do{ \
        if(1) printf(DEVICE_NAME ": " fmt, \
                 __VA_ARGS__); \
    }while(0)

/* 该宏也可以这样实现. 但其实这里回避了问题. 问题的引入是建立在可变参数部分为可以为空的基础上的,函数的可变参数就是这样的*/
#define dprintk2(...) \
    do{ \
        if(1) printf(DEVICE_NAME ": " __VA_ARGS__); \
    }while(0)


int main(void)
{
    dprintk("abc%d\n", 123);
    dprintk("abc\n");
#if 0
    dprintk1("abc%d\n", 123);
    dprintk1("abc\n");//test.c:29: error: expected expression before ')' token

#endif
    dprintk2("abc%d\n", 123);
    dprintk2("abc\n");

    return 0;
    
}