自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

paomadi的专栏

微信:MHB360

  • 博客(87)
  • 资源 (36)
  • 收藏
  • 关注

原创 一 linux spi子系统(框架)

一.spi设备struct spi_device { struct device dev; //设备文件 struct spi_master *master; //spi主机 u32 max_speed_hz; //最大速率 u8 chip_select; //片选 u8 mode; //模式 u8 bits_per_word; //一个字有多少位 int irq;

2013-02-27 14:49:20 4569

原创 MACHINE_START MACHINE_END 宏

一、定义#define MACHINE_START(_type,_name) \ //板类型,板名字static const struct machine_desc __mach_desc_##_type \ __used \ __attribute__((__section__(".arch.info.init"))) = { \ .nr = MACH_TYPE_##

2013-02-26 09:13:45 2384

原创 【android】binder机制-service

参考下mediaservice的服务,在framework/base/media/mediaservice/main_mediaservice.cpp中的main函数是mediaservice的入口函数int main(int argc, char** argv){ sp proc(ProcessState::self()); sp sm = defaultServiceMa

2013-02-06 21:49:18 1793

原创 【android】binder机制-servicemanager

servicemanager的源码在/frameworks/base/cmds/servicemanager目录下由binder.c,binder.h,service_manager.c构成生成servicemanager文件放在/system/bin/目录下servicemanager的入口是在service_manager.c中的main函数int main(int argc, c

2013-02-04 18:44:47 2191

原创 【android】binder机制 binder协议

(关于_IOWR,_IOW,_IOR,_IO请参考linux命令码(_IO宏) )一.设备文件/dev/binder ioctl命令#define BINDER_WRITE_READ _IOWR('b', 1, struct binder_write_read) //读写命令#define BINDER_SET_IDLE_TIMEOUT _IOW('b', 3, int64_t)

2013-02-03 10:14:21 2610 1

原创 linux命令码(_IO宏)

在ioctl.h头文件中定义了命令码命令码用一个32位的整型数表达bit29~31表示命令传输的方向,bit16~29记录要传输的数据的大小,bit8~15表示设备类型(一般用一个ASCII表示),bit0~7表示命令编号其中数据大小可以和方向的bit29重叠29位是特殊位,因为无方向定义值为1也就是无方向的时候会占用第29位,无方向就无所谓数据传输,所以携带数据大小段是0有方

2013-02-02 09:31:25 4140

原创 linux系统调用

一.声明系统调用的相关宏1.SYSCALL_DEFINE1~6#define SYSCALL_DEFINE1(name, ...) SYSCALL_DEFINEx(1, _##name, __VA_ARGS__)#define SYSCALL_DEFINE2(name, ...) SYSCALL_DEFINEx(2, _##name, __VA_ARGS__)#define SYSCA

2013-01-31 12:43:49 2890

原创 六 linux串口编程

一.结构体1.termiosstruct termios { tcflag_t c_iflag; /* 输入模式标志 */ tcflag_t c_oflag; /* 输出模式标志 */ tcflag_t c_cflag; /* 控制模式标志 */ tcflag_t c_lflag; /* 本地模式标志 */ cc_t c_line

2013-01-30 14:23:12 4212

原创 五 linux 串口驱动

一.串口结构体1.串口驱动结构体struct uart_driver { struct module *owner; //模块所有者 const char *driver_name; //驱动名 const char *dev_name; //设备名 int major; //主设备号 int minor; //次设备号 int nr; //支持串口个数

2013-01-29 23:25:01 3201 2

原创 四 linux tty驱动

一. tty结构体1.tty_driverstruct tty_driver { int magic; struct kref kref; //参考计数 struct cdev cdev; //字符设备 struct module *owner; //模块所有者 const char *driver_name; //驱动名 const char *name; //设

2013-01-29 23:24:42 3099

原创 三 printk如何打印信息

printk的定义可变参数 参考va_list,va_start,va_arg,va_end可变参数asmlinkage int printk(const char *fmt, ...){ va_list args; //可变参数链表 int r;#ifdef CONFIG_KGDB_KDB if (unlikely(kdb_trap_printk)) { v

2013-01-29 23:24:12 2608

原创 二 console 设备驱动

一.结构体1.consolestruct console { char name[16]; //console名 void (*write)(struct console *, const char *, unsigned); //写方法 int (*read)(struct console *, char *, unsigned); //读方法 struct tty_d

2013-01-29 23:23:51 3087 1

原创 一 uboot传递参数'console=ttyXXX'的作用

linux启动时uboot传递进console=ttyS0,115200n8的参数内核中用__setup()宏声明参数处理的方法关于__setup宏参考 early_param和__setup宏__setup("console=", console_setup);console_setup函数处理1.console_cmdline结构体struct console_cm

2013-01-29 23:23:22 4745

原创 idr机制(32叉树)

一.结构体1.idr结构体struct idr { struct idr_layer __rcu *top; //idr_layer顶层,32叉树的根 struct idr_layer *id_free; //指向idr_layer的空闲链表 int layers; //idr_layer的层数量 int id_free_cnt; //idr_layer空闲链表中剩余的

2013-01-26 10:43:48 7343 5

原创 linux多线程例子

一.基本功能1.最简单例子--创建线程/*** 创建线程**/#include #include #include void *thread1(void *arg){ printf("this thread1!\n");}int main(int argc,char **argv){ int ret; pthread_t

2013-01-24 21:14:48 1691

原创 va_list,va_start,va_arg,va_end可变参数

<!--span {font-family:'Courier New'; font-size:10pt; color:#000000}.sc2 {color:#008000}.sc4 {color:#FF8000}.sc5 {font-weight:bold; color:#0000FF}.sc10 {font-weight:bold; co

2013-01-24 21:01:36 2486

原创 early_param和__setup宏

一.宏的定义在/include/linux/Init.h中#define __setup(str, fn) \ __setup_param(str, fn, fn, 0) #define early_param(str, fn) \__setup_param(str, fn, fn, 1)两个宏都会调用__setup_param跟踪进__setup_p

2013-01-23 15:53:23 2491

原创 linux多进程多线程互斥同步例子

进程1#include #include #include #include #include #include #define DEBUG 1#define SHARE_KEY 0x1234#define THREAD_NUM 4typedef struct{ pthread_mutex_t lock; pthread_cond_t c

2013-01-22 22:31:49 2804

原创 list_for_each_entry宏

1.list_for_each_entry宏的定义#define list_for_each_entry(pos, head, member) \ for (pos = list_entry((head)->next, typeof(*pos), member); \ prefetch(pos->member.next), &pos->member != (head);

2013-01-16 11:51:25 2927

原创 linux等待队列

一.头文件#include 二.结构体1.等待队列头struct __wait_queue_head { spinlock_t lock; struct list_head task_list;};typedef struct __wait_queue_head wait_queue_head_t;2.等待队列struct __wait_queue {

2013-01-16 10:12:18 3353

原创 linux通知链相关

一.头文件#include 二.结构体//通知块 struct notifier_block { int (*notifier_call)(struct notifier_block *, unsigned long, void *); //回调函数 struct notifier_block __rcu *next; //指向通知链表的下一项 int priority

2013-01-15 21:45:31 2400

原创 linux 多线程

一.头文件#include 二.编译选项-lpthread三.结构体pthread_tpthread_attr_tpthread_barrier_tpthread_barrierattr_tpthread_cond_tpthread_condattr_tpthread_key_tpthread_mutex_tpthread_mutexattr_t

2013-01-15 16:33:32 2984

原创 linux 进程间通讯--信号量

PV的定义 P就是请求资源,V就是释放资源P(sv)    如果sv大于0,减小sv。如果sv为0,挂起这个进程的执行。V(sv)    如果有进程被挂起等待sv,使其恢复执行。如果没有进行被挂起等待sv,增加sv。P表示通过的意思,V表示释放的意思System V机制一.头文件#include 二.结构体struct sembuf {unsigned sh

2013-01-15 11:55:48 1325

原创 linux 编程--目录相关

一.头文件#include 二.结构体struct dirent {#ifndef __USE_FILE_OFFSET64 __ino_t d_ino; __off_t d_off;#else __ino64_t d_ino; __off64_t d_off;#endif unsigned short int d_re

2013-01-10 21:35:50 1047

原创 linux 定时器timer使用

1.添加头文件#include 2.定义一个timer_list结构体成员struct timer_list t1;3.初始化定时器init_timer(&t1);4.填充t1成员t1.function=&timer_fn; //回调函数t1.expires=jiffies+HZ; //定时值t1.data=HZ; //回调函数参数5.添加定时器回调函数

2013-01-04 13:08:20 4931 2

原创 list链表

一.链表头结构体struct list_head { struct list_head *next, *prev;};二.初始化链表头也就是把list的next和prew指针指向自己static inline void INIT_LIST_HEAD(struct list_head *list){ list->next = list; list->prev = lis

2013-01-03 12:19:52 1390

原创 linux 进程间通讯-共享内存

头文件#include #include #include 结构体共享内存管理结构体:struct shmid_ds {        struct ipc_perm shm_perm;          int shm_segsz;                     __kernel_time_t shm_atime;         __kerne

2013-01-03 09:55:20 1085

原创 五、从usb的插入开始

当usb设备插入接口,电压变化会通知到usb主控器,触发主控器中断,如果主控器不支持中断,那么会使用rh_timer方法,轮询接口其结果都是调用usb_hcd_poll_rh_statusvoid usb_hcd_poll_rh_status(struct usb_hcd *hcd){ struct urb *urb; int length; unsigned lon

2012-12-29 14:04:34 5600 1

原创 四、usb设备注册

一.usb设备驱动注册static inline int usb_register(struct usb_driver *driver){ return usb_register_driver(driver, THIS_MODULE, KBUILD_MODNAME);}usb_register_driverint usb_register_driver(struct usb

2012-12-29 14:04:00 2874

原创 三、usb主控器注册

第一步usb主控器设备的分配usb_create_hcdstruct usb_hcd *usb_create_hcd (const struct hc_driver *driver,struct device *dev, const char *bus_name){ struct usb_hcd *hcd; hcd = kzalloc(sizeof(*hcd) + driver

2012-12-29 14:03:39 3671

原创 二、usb子系统初始化

在/drivers/usb/core/Usb.c中,subsys_initcall(usb_init)声明了usb子系统入口函数usb_initstatic int __init usb_init(void){ int retval; if (nousb) { pr_info("%s: USB support disabled\n", usbcore_name); re

2012-12-29 14:02:20 4964

原创 linux特殊设备驱动

一. 内存设备结构体static const struct memdev { const char *name; mode_t mode; const struct file_operations *fops; struct backing_dev_info *dev_info;} devlist[] = { [1] = { "mem", 0, &mem_fops,

2012-12-22 21:42:15 1290

原创 linux i2c设备驱动

一. i2c的结构体     1. i2c适配器struct i2c_adapter { struct module *owner; //模块所有者 unsigned int id __deprecated; unsigned int class; //支持的类别(I2C_CLASS_HWMON,I2C_CLASS_DDC,I2C_CLASS_SPD) const stru

2012-12-22 17:27:07 3285

原创 linux input设备驱动

一. 输入设备结构体     1. input_dev 输入设备struct input_dev { const char *name; //设备名 const char *phys; //设备系统层的物理路径 const char *uniq; // struct input_id id; //输入设备id 总线类型;厂商编号,产品id,产品版本 unsig

2012-12-21 22:54:21 4553

原创 linux framebuffer设备驱动

一. framebuffer结构体     1. fb_infostruct fb_info { int node; //次设备号 int flags; struct mutex lock; struct mutex mm_lock; struct fb_var_screeninfo var; //可变参数 struct fb_fix_screeninfo f

2012-12-21 11:02:29 2706

原创 linux块设备驱动

杂记一. 块设备相关结构体块设备结构体struct block_device { dev_t bd_dev; //设备号 struct inode * bd_inode; /* will die */ struct super_block * bd_super; //超级块 int bd_openers; struct mutex bd_mutex; /*

2012-12-20 10:24:09 1391

原创 container_of宏

一. 作用struct XXX_dev{ cdev cdev;}struct XXX_dev *dev; /* device information */  *dev             = container_of(inode->i_cdev, struct XXX_dev, cdev); 结构体对象                                 域

2012-12-19 14:54:48 1681

原创 linux RTC设备驱动

一. RTC设备结构体struct rtc_device{ struct device dev; //设备文件 struct module *owner; //模块所有者 int id; //RTC次设备 char name[RTC_DEVICE_NAME_SIZE]; //RTC设备名 const struct rtc_class_ops *ops; //RTC

2012-12-19 14:06:04 3094

原创 总线、设备、驱动、类

一. 总线、设备、驱动、类各自的相关结构体    1.总线     1.1 总线类型结构体struct bus_type { const char *name; //总线类型名 struct bus_attribute *bus_attrs; //总线属性 struct device_attribute *dev_attrs; //设备属性 struct driver_

2012-12-18 21:40:06 2285

原创 linux platform平台设备驱动

一. 平台总线    1. 总线结构体struct bus_type platform_bus_type = { .name = "platform", //总线名 .dev_attrs = platform_dev_attrs, //设备属性 .match = platform_match, //匹配函数 .uevent = platform_uevent,

2012-12-18 13:40:22 1639

linux 2+1+2

Understanding the Linux Virtual Memory Manager Understanding Linux Network Internals Understanding The Linux Kernel 3 Linux Kernel Development 3 Linux Device driver 3 全部都是英文版

2012-08-20

Windows 7 USB_DVD tool

windows7 u盘安装工具 windows7 u盘安装工具 windows7 u盘安装工具

2010-12-23

Universal-USB-Installer-1.8.1.5.exe

Universal-USB-Installer-1.8.1.5.exeUniversal-USB-Installer-1.8.1.5.exeUniversal-USB-Installer-1.8.1.5.exeUniversal-USB-Installer-1.8.1.5.exe

2010-12-02

Advanced_Programming_In_The_UNIX_Environment(2005)2Ed

Advanced_Programming_In_The_UNIX_Environment(2005)2Ed.pdfAdvanced_Programming_In_The_UNIX_Environment(2005)2Ed.pdfAdvanced_Programming_In_The_UNIX_Environment(2005)2Ed.pdfAdvanced_Programming_In_The_UNIX_Environment(2005)2Ed.pdfAdvanced_Programming_In_The_UNIX_Environment(2005)2Ed.pdfAdvanced_Programming_In_The_UNIX_Environment(2005)2Ed.pdfAdvanced_Programming_In_The_UNIX_Environment(2005)2Ed.pdf

2010-12-02

SoftICE for XP

  SoftICE是Compuware NuMega公司[1]的产品,是目前公认最好的系统级调试工具!兼容性和稳定性极好,可在源代码级调试各种应用程序和设备驱动程序,也可使用TCP/IP连接进行远程调试。ICE的含义   ICE(In Circuit Emulator)即实体电路模拟器,是用来跟踪软件执行动作细节的一个模拟CPU的电子设备。当然这种设备价格昂贵,不是常人所能拥有的。NuMega公司推出的Soft "ICE",意思是靠软件实现ICE的功能。   SoftICE单独发行的最高版本是SoftICE v4.3.2.2485,针对不同平台推出的相应的版本:DOS,Windows3.x,Windows 9x,Windows NT和Windows 2000。

2010-11-06

coreutils linux终端源码

coreutils-8.5.tar.gz 贴段CAT的大伙瞅瞅 /* cat -- concatenate files and print on the standard output. Copyright (C) 1988, 1990-1991, 1995-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* Differences from the Unix cat: * Always unbuffered, -u is ignored. * Usually much faster than other versions of cat, the difference is especially apparent when using the -v option. By [email protected], Torbjorn Granlund, advised by rms, Richard Stallman. */ #include <config.h> #include <stdio.h> #include <getopt.h> #include <sys/types.h> #if HAVE_STROPTS_H # include <stropts.h> #endif #if HAVE_SYS_IOCTL_H # include <sys/ioctl.h> #endif #include "system.h" #include "error.h" #include "full-write.h" #include "quote.h" #include "safe-read.h" #include "xfreopen.h" /* The official name of this program (e.g., no `g' prefix). */ #define PROGRAM_NAME "cat" #define AUTHORS \ proper_name_utf8 ("Torbjorn Granlund", "Torbj\303\266rn Granlund"), \ proper_name ("Richard M. Stallman") /* Name of input file. May be "-". */ static char const *infile; /* Descriptor on which input file is open. */ static int input_desc; /* Buffer for line numbers. An 11 digit counter may overflow within an hour on a P2/466, an 18 digit counter needs about 1000y */ #define LINE_COUNTER_BUF_LEN 20 static char line_buf[LINE_COUNTER_BUF_LEN] = { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '0', '\t', '\0' }; /* Position in `line_buf' where printing starts. This will not change unless the number of lines is larger than 999999. */ static char *line_num_print = line_buf + LINE_COUNTER_BUF_LEN - 8; /* Position of the first digit in `line_buf'. */ static char *line_num_start = line_buf + LINE_COUNTER_BUF_LEN - 3; /* Position of the last digit in `line_buf'. */ static char *line_num_end = line_buf + LINE_COUNTER_BUF_LEN - 3; /* Preserves the `cat' function's local `newlines' between invocations. */ static int newlines2 = 0; void usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), program_name); else { printf (_("\ Usage: %s [OPTION]... [FILE]...\n\ "), program_name); fputs (_("\ Concatenate FILE(s), or standard input, to standard output.\n\ \n\ -A, --show-all equivalent to -vET\n\ -b, --number-nonblank number nonempty output lines\n\ -e equivalent to -vE\n\ -E, --show-ends display $ at end of each line\n\ -n, --number number all output lines\n\ -s, --squeeze-blank suppress repeated empty output lines\n\ "), stdout); fputs (_("\ -t equivalent to -vT\n\ -T, --show-tabs display TAB characters as ^I\n\ -u (ignored)\n\ -v, --show-nonprinting use ^ and M- notation, except for LFD and TAB\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); fputs (_("\ \n\ With no FILE, or when FILE is -, read standard input.\n\ "), stdout); printf (_("\ \n\ Examples:\n\ %s f - g Output f's contents, then standard input, then g's contents.\n\ %s Copy standard input to standard output.\n\ "), program_name, program_name); emit_ancillary_info (); } exit (status); } /* Compute the next line number. */ static void next_line_num (void) { char *endp = line_num_end; do { if ((*endp)++ < '9') return; *endp-- = '0'; } while (endp >= line_num_start); if (line_num_start > line_buf) *--line_num_start = '1'; else *line_buf = '>'; if (line_num_start < line_num_print) line_num_print--; } /* Plain cat. Copies the file behind `input_desc' to STDOUT_FILENO. Return true if successful. */ static bool simple_cat ( /* Pointer to the buffer, used by reads and writes. */ char *buf, /* Number of characters preferably read or written by each read and write call. */ size_t bufsize) { /* Actual number of characters read, and therefore written. */ size_t n_read; /* Loop until the end of the file. */ for (;;) { /* Read a block of input. */ n_read = safe_read (input_desc, buf, bufsize); if (n_read == SAFE_READ_ERROR) { error (0, errno, "%s", infile); return false; } /* End of this file? */ if (n_read == 0) return true; /* Write this block out. */ { /* The following is ok, since we know that 0 < n_read. */ size_t n = n_read; if (full_write (STDOUT_FILENO, buf, n) != n) error (EXIT_FAILURE, errno, _("write error")); } } } /* Write any pending output to STDOUT_FILENO. Pending is defined to be the *BPOUT - OUTBUF bytes starting at OUTBUF. Then set *BPOUT to OUTPUT if it's not already that value. */ static inline void write_pending (char *outbuf, char **bpout) { size_t n_write = *bpout - outbuf; if (0 < n_write) { if (full_write (STDOUT_FILENO, outbuf, n_write) != n_write) error (EXIT_FAILURE, errno, _("write error")); *bpout = outbuf; } } /* Cat the file behind INPUT_DESC to the file behind OUTPUT_DESC. Return true if successful. Called if any option more than -u was specified. A newline character is always put at the end of the buffer, to make an explicit test for buffer end unnecessary. */ static bool cat ( /* Pointer to the beginning of the input buffer. */ char *inbuf, /* Number of characters read in each read call. */ size_t insize, /* Pointer to the beginning of the output buffer. */ char *outbuf, /* Number of characters written by each write call. */ size_t outsize, /* Variables that have values according to the specified options. */ bool show_nonprinting, bool show_tabs, bool number, bool number_nonblank, bool show_ends, bool squeeze_blank) { /* Last character read from the input buffer. */ unsigned char ch; /* Pointer to the next character in the input buffer. */ char *bpin; /* Pointer to the first non-valid byte in the input buffer, i.e. the current end of the buffer. */ char *eob; /* Pointer to the position where the next character shall be written. */ char *bpout; /* Number of characters read by the last read call. */ size_t n_read; /* Determines how many consecutive newlines there have been in the input. 0 newlines makes NEWLINES -1, 1 newline makes NEWLINES 1, etc. Initially 0 to indicate that we are at the beginning of a new line. The "state" of the procedure is determined by NEWLINES. */ int newlines = newlines2; #ifdef FIONREAD /* If nonzero, use the FIONREAD ioctl, as an optimization. (On Ultrix, it is not supported on NFS file systems.) */ bool use_fionread = true; #endif /* The inbuf pointers are initialized so that BPIN > EOB, and thereby input is read immediately. */ eob = inbuf; bpin = eob + 1; bpout = outbuf; for (;;) { do { /* Write if there are at least OUTSIZE bytes in OUTBUF. */ if (outbuf + outsize <= bpout) { char *wp = outbuf; size_t remaining_bytes; do { if (full_write (STDOUT_FILENO, wp, outsize) != outsize) error (EXIT_FAILURE, errno, _("write error")); wp += outsize; remaining_bytes = bpout - wp; } while (outsize <= remaining_bytes); /* Move the remaining bytes to the beginning of the buffer. */ memmove (outbuf, wp, remaining_bytes); bpout = outbuf + remaining_bytes; } /* Is INBUF empty? */ if (bpin > eob) { bool input_pending = false; #ifdef FIONREAD int n_to_read = 0; /* Is there any input to read immediately? If not, we are about to wait, so write all buffered output before waiting. */ if (use_fionread && ioctl (input_desc, FIONREAD, &n_to_read) < 0) { /* Ultrix returns EOPNOTSUPP on NFS; HP-UX returns ENOTTY on pipes. SunOS returns EINVAL and More/BSD returns ENODEV on special files like /dev/null. Irix-5 returns ENOSYS on pipes. */ if (errno == EOPNOTSUPP || errno == ENOTTY || errno == EINVAL || errno == ENODEV || errno == ENOSYS) use_fionread = false; else { error (0, errno, _("cannot do ioctl on %s"), quote (infile)); newlines2 = newlines; return false; } } if (n_to_read != 0) input_pending = true; #endif if (!input_pending) write_pending (outbuf, &bpout); /* Read more input into INBUF. */ n_read = safe_read (input_desc, inbuf, insize); if (n_read == SAFE_READ_ERROR) { error (0, errno, "%s", infile); write_pending (outbuf, &bpout); newlines2 = newlines; return false; } if (n_read == 0) { write_pending (outbuf, &bpout); newlines2 = newlines; return true; } /* Update the pointers and insert a sentinel at the buffer end. */ bpin = inbuf; eob = bpin + n_read; *eob = '\n'; } else { /* It was a real (not a sentinel) newline. */ /* Was the last line empty? (i.e. have two or more consecutive newlines been read?) */ if (++newlines > 0) { if (newlines >= 2) { /* Limit this to 2 here. Otherwise, with lots of consecutive newlines, the counter could wrap around at INT_MAX. */ newlines = 2; /* Are multiple adjacent empty lines to be substituted by single ditto (-s), and this was the second empty line? */ if (squeeze_blank) { ch = *bpin++; continue; } } /* Are line numbers to be written at empty lines (-n)? */ if (number && !number_nonblank) { next_line_num (); bpout = stpcpy (bpout, line_num_print); } } /* Output a currency symbol if requested (-e). */ if (show_ends) *bpout++ = '$'; /* Output the newline. */ *bpout++ = '\n'; } ch = *bpin++; } while (ch == '\n'); /* Are we at the beginning of a line, and line numbers are requested? */ if (newlines >= 0 && number) { next_line_num (); bpout = stpcpy (bpout, line_num_print); } /* Here CH cannot contain a newline character. */ /* The loops below continue until a newline character is found, which means that the buffer is empty or that a proper newline has been found. */ /* If quoting, i.e. at least one of -v, -e, or -t specified, scan for chars that need conversion. */ if (show_nonprinting) { for (;;) { if (ch >= 32) { if (ch < 127) *bpout++ = ch; else if (ch == 127) { *bpout++ = '^'; *bpout++ = '?'; } else { *bpout++ = 'M'; *bpout++ = '-'; if (ch >= 128 + 32) { if (ch < 128 + 127) *bpout++ = ch - 128; else { *bpout++ = '^'; *bpout++ = '?'; } } else { *bpout++ = '^'; *bpout++ = ch - 128 + 64; } } } else if (ch == '\t' && !show_tabs) *bpout++ = '\t'; else if (ch == '\n') { newlines = -1; break; } else { *bpout++ = '^'; *bpout++ = ch + 64; } ch = *bpin++; } } else { /* Not quoting, neither of -v, -e, or -t specified. */ for (;;) { if (ch == '\t' && show_tabs) { *bpout++ = '^'; *bpout++ = ch + 64; } else if (ch != '\n') *bpout++ = ch; else { newlines = -1; break; } ch = *bpin++; } } } } int main (int argc, char **argv) { /* Optimal size of i/o operations of output. */ size_t outsize; /* Optimal size of i/o operations of input. */ size_t insize; size_t page_size = getpagesize (); /* Pointer to the input buffer. */ char *inbuf; /* Pointer to the output buffer. */ char *outbuf; bool ok = true; int c; /* Index in argv to processed argument. */ int argind; /* Device number of the output (file or whatever). */ dev_t out_dev; /* I-node number of the output. */ ino_t out_ino; /* True if the output file should not be the same as any input file. */ bool check_redirection = true; /* Nonzero if we have ever read standard input. */ bool have_read_stdin = false; struct stat stat_buf; /* Variables that are set according to the specified options. */ bool number = false; bool number_nonblank = false; bool squeeze_blank = false; bool show_ends = false; bool show_nonprinting = false; bool show_tabs = false; int file_open_mode = O_RDONLY; static struct option const long_options[] = { {"number-nonblank", no_argument, NULL, 'b'}, {"number", no_argument, NULL, 'n'}, {"squeeze-blank", no_argument, NULL, 's'}, {"show-nonprinting", no_argument, NULL, 'v'}, {"show-ends", no_argument, NULL, 'E'}, {"show-tabs", no_argument, NULL, 'T'}, {"show-all", no_argument, NULL, 'A'}, {GETOPT_HELP_OPTION_DECL}, {GETOPT_VERSION_OPTION_DECL}, {NULL, 0, NULL, 0} }; initialize_main (&argc, &argv); set_program_name (argv[0]); setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); /* Arrange to close stdout if we exit via the case_GETOPT_HELP_CHAR or case_GETOPT_VERSION_CHAR code. Normally STDOUT_FILENO is used rather than stdout, so close_stdout does nothing. */ atexit (close_stdout); /* Parse command line options. */ while ((c = getopt_long (argc, argv, "benstuvAET", long_options, NULL)) != -1) { switch (c) { case 'b': number = true; number_nonblank = true; break; case 'e': show_ends = true; show_nonprinting = true; break; case 'n': number = true; break; case 's': squeeze_blank = true; break; case 't': show_tabs = true; show_nonprinting = true; break; case 'u': /* We provide the -u feature unconditionally. */ break; case 'v': show_nonprinting = true; break; case 'A': show_nonprinting = true; show_ends = true; show_tabs = true; break; case 'E': show_ends = true; break; case 'T': show_tabs = true; break; case_GETOPT_HELP_CHAR; case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); default: usage (EXIT_FAILURE); } } /* Get device, i-node number, and optimal blocksize of output. */ if (fstat (STDOUT_FILENO, &stat_buf) < 0) error (EXIT_FAILURE, errno, _("standard output")); outsize = io_blksize (stat_buf); /* Input file can be output file for non-regular files. fstat on pipes returns S_IFSOCK on some systems, S_IFIFO on others, so the checking should not be done for those types, and to allow things like cat < /dev/tty > /dev/tty, checking is not done for device files either. */ if (S_ISREG (stat_buf.st_mode)) { out_dev = stat_buf.st_dev; out_ino = stat_buf.st_ino; } else { check_redirection = false; #ifdef lint /* Suppress `used before initialized' warning. */ out_dev = 0; out_ino = 0; #endif } if (! (number || show_ends || squeeze_blank)) { file_open_mode |= O_BINARY; if (O_BINARY && ! isatty (STDOUT_FILENO)) xfreopen (NULL, "wb", stdout); } /* Check if any of the input files are the same as the output file. */ /* Main loop. */ infile = "-"; argind = optind; do { if (argind < argc) infile = argv[argind]; if (STREQ (infile, "-")) { have_read_stdin = true; input_desc = STDIN_FILENO; if ((file_open_mode & O_BINARY) && ! isatty (STDIN_FILENO)) xfreopen (NULL, "rb", stdin); } else { input_desc = open (infile, file_open_mode); if (input_desc < 0) { error (0, errno, "%s", infile); ok = false; continue; } } if (fstat (input_desc, &stat_buf) < 0) { error (0, errno, "%s", infile); ok = false; goto contin; } insize = io_blksize (stat_buf); /* Compare the device and i-node numbers of this input file with the corresponding values of the (output file associated with) stdout, and skip this input file if they coincide. Input files cannot be redirected to themselves. */ if (check_redirection && stat_buf.st_dev == out_dev && stat_buf.st_ino == out_ino && (input_desc != STDIN_FILENO)) { error (0, 0, _("%s: input file is output file"), infile); ok = false; goto contin; } /* Select which version of `cat' to use. If any format-oriented options were given use `cat'; otherwise use `simple_cat'. */ if (! (number || show_ends || show_nonprinting || show_tabs || squeeze_blank)) { insize = MAX (insize, outsize); inbuf = xmalloc (insize + page_size - 1); ok &= simple_cat (ptr_align (inbuf, page_size), insize); } else { inbuf = xmalloc (insize + 1 + page_size - 1); /* Why are (OUTSIZE - 1 + INSIZE * 4 + LINE_COUNTER_BUF_LEN + PAGE_SIZE - 1) bytes allocated for the output buffer? A test whether output needs to be written is done when the input buffer empties or when a newline appears in the input. After output is written, at most (OUTSIZE - 1) bytes will remain in the buffer. Now INSIZE bytes of input is read. Each input character may grow by a factor of 4 (by the prepending of M-^). If all characters do, and no newlines appear in this block of input, we will have at most (OUTSIZE - 1 + INSIZE * 4) bytes in the buffer. If the last character in the preceding block of input was a newline, a line number may be written (according to the given options) as the first thing in the output buffer. (Done after the new input is read, but before processing of the input begins.) A line number requires seldom more than LINE_COUNTER_BUF_LEN positions. Align the output buffer to a page size boundary, for efficency on some paging implementations, so add PAGE_SIZE - 1 bytes to the request to make room for the alignment. */ outbuf = xmalloc (outsize - 1 + insize * 4 + LINE_COUNTER_BUF_LEN + page_size - 1); ok &= cat (ptr_align (inbuf, page_size), insize, ptr_align (outbuf, page_size), outsize, show_nonprinting, show_tabs, number, number_nonblank, show_ends, squeeze_blank); free (outbuf); } free (inbuf); contin: if (!STREQ (infile, "-") && close (input_desc) < 0) { error (0, errno, "%s", infile); ok = false; } } while (++argind < argc); if (have_read_stdin && close (STDIN_FILENO) < 0) error (EXIT_FAILURE, errno, _("closing standard input")); exit (ok ? EXIT_SUCCESS : EXIT_FAILURE); }

2010-09-02

protues最好的教程

Isis ares vsm 仿真器件的使用 画板 原理图 封装图 元件库 虚拟串口

2010-08-13

ANSI C c99规范

ANSI C c99规范

2010-08-13

网络调试助手+串口调试助手

网络调试助手+串口调试助手网络调试助手+串口调试助手网络调试助手+串口调试助手网络调试助手+串口调试助手网络调试助手+串口调试助手网络调试助手+串口调试助手

2010-08-11

----串口调试器----

串口调试手串口调试手串口调试手串口调试手串口调试手

2010-08-11

SD卡 物理层协议

1. General Description............................................................................................................1 2. System Features .................................................................................................................3 3. SD Memory Card System Concept ....................................................................................5 3.1 Read-Write Property......................................................................................................................5 3.2 Supply Voltage...............................................................................................................................5 3.3 Card Capacity................................................................................................................................5 3.4 Speed Class ..................................................................................................................................6 3.5 Bus Topology .................................................................................................................................7 3.6 Bus Protocol ..................................................................................................................................7 3.6.1 SD Bus....................................................................................................................................7 3.6.2 SPI Bus .................................................................................................................................10 3.7 SD Memory Card–Pins and Registers......................................................................................... 11 4. SD Memory Card Functional Description .......................................................................12 4.1 General ........................................................................................................................................12 4.2 Card Identification Mode..............................................................................................................13 4.2.1 Card Reset ............................................................................................................................13 4.2.2 Operating Condition Validation..............................................................................................13 4.2.3 Card Initialization and Identification Process ........................................................................15 4.3 Data Transfer Mode.....................................................................................................................17 4.3.1 Wide Bus Selection/Deselection ...........................................................................................19 4.3.2 2 GByte Card ........................................................................................................................19 4.3.3 Data Read.............................................................................................................................19 4.3.4 Data Write .............................................................................................................................20 4.3.5 Erase.....................................................................................................................................22 4.3.6 Write Protect Management ...................................................................................................22 4.3.7 Card Lock/Unlock Operation.................................................................................................23 4.3.7.1 General ................................................................................................................................. 23 4.3.7.2 Parameter and the Result of CMD42.................................................................................... 25 4.3.7.3 Forcing Erase ....................................................................................................................... 27 4.3.7.3.1 Force Erase Function to the Locked Card...................................................................... 27 4.3.7.4 Relation Between ACMD6 and Lock/Unlock State................................................................ 28 4.3.7.5 Commands Accepted for Locked Card ................................................................................. 28 4.3.7.6 Two Types of Lock/Unlock Card............................................................................................ 29 4.3.8 Content Protection ................................................................................................................29 4.3.9 Application-Specific Commands............................................................................................29 4.3.9.1 Application-Specific Command – APP_CMD (CMD55)......................................................... 29 4.3.9.2 General Command - GEN_CMD (CMD56) ........................................................................... 30 4.3.10 Switch Function Command .................................................................................................31 4.3.10.1 General ............................................................................................................................... 31 4.3.10.2 Mode 0 Operation - Check Function ................................................................................... 32 4.3.10.3 Mode 1 Operation - Set Function........................................................................................33 4.3.10.4 Switch Function Status........................................................................................................ 35 4.3.10.4.1 Busy Status Indication for Functions ............................................................................ 36 4.3.10.4.2 Data Structure Version ................................................................................................. 37 4.3.10.4.3 Function Table of Switch Command............................................................................. 37 4.3.10.5 Relationship between CMD6 data & other commands ....................................................... 38 4.3.10.6 Switch Function Flow Example...........................................................................................38 4.3.10.7 Example of Checking.......................................................................................................... 38 4.3.11 High-Speed Mode (25 MB/sec interface speed)..................................................................39 4.3.12 Command System...............................................................................................................39 4.3.13 Send Interface Condition Command (CMD8) .....................................................................40 4.3.14 Command Functional Difference in High Capacity SD Memory Card.................................41 4.4 Clock Control ...............................................................................................................................42 4.5 Cyclic Redundancy Code (CRC) .................................................................................................43 4.6 Error Conditions...........................................................................................................................45 4.6.1 CRC and Illegal Command ...................................................................................................45 4.6.2 Read, Write and Erase Timeout Conditions ..........................................................................45 4.6.2.1 Read ..................................................................................................................................... 45 4.6.2.2 Write ..................................................................................................................................... 45 4.6.2.3 Erase .................................................................................................................................... 45 4.7 Commands ..................................................................................................................................46 4.7.1 Command Types ...................................................................................................................46 4.7.2 Command Format .................................................................................................................46 4.7.3 Command Classes................................................................................................................46 4.7.4 Detailed Command Description ............................................................................................49 4.8 Card State Transition Table .........................................................................................................56 4.8 Card State Transition Table .........................................................................................................56 4.9 Responses...................................................................................................................................58 4.9.1 R1 (normal response command):..........................................................................................58 4.9.2 R1b........................................................................................................................................58 4.9.3 R2 (CID, CSD register) .........................................................................................................58 4.9.4 R3 (OCR register) .................................................................................................................59 4.9.5 R6 (Published RCA response) ..............................................................................................59 4.9.6 R7 (Card interface condition) ................................................................................................59 4.10 Two Status Information of SD Memory Card .............................................................................61 4.10.1 Card Status .........................................................................................................................61 4.10.2 SD Status ............................................................................................................................65 4.11 Memory Array Partitioning .........................................................................................................68 4.12 Timings ......................................................................................................................................68 4.13 Speed Class Specification .........................................................................................................69 4.13.1 Allocation Unit (AU) .............................................................................................................69 4.13.2 Recording Unit (RU)............................................................................................................69 4.13.3 Write Performance ..............................................................................................................69 4.13.4 Read Performance..............................................................................................................69 4.13.5 Performance Curve Definition.............................................................................................69 4.13.6 Speed Class Definition........................................................................................................69 4.13.7 Consideration for Inserting FAT Update during Recording..................................................70 4.13.8 Measurement Conditions and Requirements of the Speed Class.......................................70 4.14 Erase Timeout Calculation.........................................................................................................71 4.14.1 Erase Unit ...........................................................................................................................71 4.14.2 Case Analysis of Erase Time Characteristics......................................................................71 4.14.3 Method for Erase Large Areas ............................................................................................72 4.14.4 Calculation of Erase Timeout Value Using the Parameter Registers ..................................72 5. Card Registers ..................................................................................................................73 5.1 OCR register................................................................................................................................74 5.2 CID register .................................................................................................................................75 5.3 CSD Register...............................................................................................................................77 5.3.1 CSD_STRUCTURE ..............................................................................................................77 5.3.2 CSD Register (CSD Version 1.0) ..........................................................................................78 5.3.3 CSD Register (CSD Version 2.0) ..........................................................................................86 5.4 RCA register ................................................................................................................................89 5.5 DSR register (Optional) ...............................................................................................................89 5.6 SCR register ................................................................................................................................89 6. SD Memory Card Hardware Interface..............................................................................91 6.1 Hot Insertion and Removal ..........................................................................................................91 6.2 Card Detection (Insertion/Removal) ............................................................................................91 6.3 Power Protection (Insertion/Removal) .........................................................................................91 6.4 Power Scheme ............................................................................................................................91 6.4.1 Power Up ..............................................................................................................................91 6.4.2 Power Down and Power Cycle..............................................................................................92 6.5 Programmable Card Output Driver (Optional) .............................................................................92 6.6 Bus Operating Conditions............................................................................................................92 6.7 Bus Timing (Default) ....................................................................................................................92 6.8 Bus Timing (High-Speed Mode)...................................................................................................92 7. SPI Mode............................................................................................................................93 7.1 Introduction..................................................................................................................................93 7.2 SPI Bus Protocol .........................................................................................................................93 7.2.1 Mode Selection and Initialization...........................................................................................94 7.2.2 Bus Transfer Protection.........................................................................................................96 7.2.3 Data Read.............................................................................................................................96 7.2.4 Data Write .............................................................................................................................97 7.2.5 Erase & Write Protect Management......................................................................................98 7.2.6 Read CID/CSD Registers......................................................................................................99 7.2.7 Reset Sequence....................................................................................................................99 7.2.8 Error Conditions ....................................................................................................................99 7.2.9 Memory Array Partitioning.....................................................................................................99 7.2.10 Card Lock/Unlock................................................................................................................99 7.2.11 Application Specific Commands ..........................................................................................99 7.2.12 Content Protection Command.............................................................................................99 7.2.13 Switch Function Command ...............................................................................................100 7.2.14 High-Speed Mode .............................................................................................................100 7.2.15 Speed Class Specification.................................................................................................100 7.3 SPI Mode Transaction Packets .................................................................................................101 7.3.1 Command Tokens ...............................................................................................................101 7.3.1.1 Command Format ............................................................................................................... 101 7.3.1.2 Command Classes ............................................................................................................. 101 7.3.1.3 Detailed Command Description .......................................................................................... 102 7.3.1.4 Card Operation for CMD8 in SPI mode .............................................................................. 108 7.3.2 Responses ..........................................................................................................................109 7.3.2.1 Format R1........................................................................................................................... 109 7.3.2.2 Format R1b......................................................................................................................... 109 7.3.2.3 Format R2............................................................................................................................110 7.3.2.4 Format R3............................................................................................................................110 7.3.2.5 Formats R4 & R5 .................................................................................................................111 7.3.2.6 Format R7............................................................................................................................111 7.3.3 Control Tokens .................................................................................................................... 111 7.3.3.1 Data Response Token..........................................................................................................111 7.3.3.2 Start Block Tokens and Stop Tran Token..............................................................................111 7.3.3.3 Data Error Token..................................................................................................................112 7.3.4 Clearing Status Bits............................................................................................................. 113 7.4 Card Registers........................................................................................................................... 114 7.5 SPI Bus Timing Diagrams.......................................................................................................... 114 7.6 SPI Electrical Interface .............................................................................................................. 114 7.7 SPI Bus Operating Conditions................................................................................................... 114 7.8 Bus Timing................................................................................................................................. 114 8. SD Memory Card Mechanical Specification .................................................................115 Appendix A..........................................................................................................................116 A.1 Connector.................................................................................................................................. 116 A.2 Related Documentation............................................................................................................. 116 Appendix B..........................................................................................................................117 B.1 Abbreviations and terms............................................................................................................ 117

2010-08-03

C # 记事本源代码

打印功能没实现,其他都差不多了的,发现bug跟我说下 C # 记事本源代码C # 记事本源代码C # 记事本源代码C # 记事本源代码C # 记事本源代码C # 记事本源代码C # 记事本源代码C # 记事本源代码C # 记事本源代码C # 记事本源代码C # 记事本源代码C # 记事本源代码C # 记事本源代码C # 记事本源代码C # 记事本源代码

2010-07-23

ARM7芯片 LPC2103

数据手册 datasheet 用户手册 User manual 头文件 lpc2103.H 都是标准的资料

2010-07-23

PS/2键盘驱动设计指南

针脚分布图 引脚定义 第二套扫描码 小键盘的也有 读写时序图 数据位的定义解释 硬件电路图 源码 wps文件 用word可以打开

2010-07-23

Linux DeviceDrivers 3rd Edition

(英文版 第三版 中文书签我自己做的 大家要是不喜欢就用福听PDF删除掉我加上去的东西 我还有很多好资源 大家都去逛逛 还有这个是单本的 网上还有个分很多章的) 前言 1 第一章 设备驱动程序简介 9 设备驱动程序的作用 10 内核功能划分 12 设备和模块的分类 14 安全问题 15 版本编号 17 许可证条款 18 加入内核开发社团 19 本书概要 19 第二章 构造和运行模块 21 设置测试系统 21 Hello World模块 22 核心模块与应用程序的对比 24 编译和装载 28 内核符号表 33 预备知识 35 初始化和关闭 36 模块参数 40 在用户空间编写驱动程序 42 .快速参考 44 第三章 字符设备驱动程序 46 scull的设计 46 主设备号和次设备号 47 一些重要的数据结构 53 字符设备的注册 59 open和release 62 scull的内存使用 64 read和write 67 试试新设备 74 快速参考 74 第四章 调试技术 76 内核中的调试支持 76 通过打印调试 78 通过查询调试 85 通过监视调试 94 调试系统故障 96 调试器和相关工具 102 第五章 并发和竞态 109 scull的缺陷 109 并发及其管理 110 信号量和互斥体 111 completion 116 自旋锁 118 锁陷阱 123 除了锁之外的办法 125 快速参考 132 第六章 高级字符驱动程序操作 137 ioctl 137 阻塞型I/O 149 poll和select 163 异步通知 168 定位设备 172 设备文件的访问控制 173 快速参考 179 第七章 时间、延迟及延缓操作 183 度量时间差 183 获取当前时间 188 延迟执行 190 内核定时器 196 tasklet 202 工作队列 204 快速参考 208 第八章 分配内存 213 kmalloc函数的内幕 213 后备高速缓存 217 get_free_page和相关函数 221 vmalloc及其辅助函数 225 per-CPU变量 228 获取大的缓冲区 230 快速参考 231 第九章 与硬件通信 235 I/O端口和I/O内存 235 使用I/O端口 239 I/O端口示例 245 使用I/O内存 248 快速参考 254 第十章 中断处理 258 准备并口 259 安装中断处理例程 259 实现中断处理例程 269 顶半部和底半部 274 中断共享 278 中断驱动的I/O 281 快速参考 285 第十一章 内核的数据类型 287 使用标准C语言类型 287 为数据项分配确定的空间大小 289 接口特定的类型 289 其他有关移植性的问题 291 链表 294 快速参考 298 第十二章 PCI驱动程序 300 PCI接口 300 ISA回顾 317 PC/104和PC/104+ 319 其他的PC总线 319 SBus 320 NuBus 321 外部总线 321 快速参考 322 第十三章 USB驱动程序 324 USB设备基础 326 USB和Sysfs 329 USB urb 331 编写USB驱动程序 342 不使用urb的USB传输 352 快速参考 356 第十四章 Linux设备模型 359 kobject、kset和子系统 361 低层sysfs操作 368 热插拔事件的产生 372 总线、设备和驱动程序 374 类 384 各环节的整合 388 热插拔 394 处理固件 401 快速索引 403 第十五章 内存映射和DMA 408 Linux的内存管理 408 mmap设备操作 418 执行直接I/O访问 429 直接内存访问 435 快速参考 453 第十六章 块设备驱动程序 458 注册 459 块设备操作 464 请求处理 468 其他一些细节 484 快速参考 487 第十七章 网络驱动程序 491 snull设计 492 连接到内核 495 net_device结构细节 499 打开和关闭 508 数据包传输 510 数据包的接收 514 中断处理例程 516 不使用接收中断 518 链路状态的改变 521 套接字缓冲区 521 MAC 地址解析 525 定制 ioctl 命令 527 统计信息 528 组播 529 其他知识点详解 533 快速参考 534 第十八章 TTY驱动

2010-07-23

华为PCB布线规范 华为PCB布线规范

华为PCB布线规范华为PCB布线规范华为PCB布线规范华为PCB布线规范华为PCB布线规范华为PCB布线规范华为PCB布线规范华为PCB布线规范华为PCB布线规范华为PCB布线规范华为PCB布线规范华为PCB布线规范华为PCB布线规范华为PCB布线规范华为PCB布线规范华为PCB布线规范华为PCB布线规范华为PCB布线规范华为PCB布线规范华为PCB布线规范华为PCB布线规范华为PCB布线规范华为PCB布线规范华为PCB布线规范华为PCB布线规范华为PCB布线规范华为PCB布线规范华为PCB布线规范华为PCB布线规范华为PCB布线规范华为PCB布线规范华为PCB布线规范华为PCB布线规范华为PCB布线规范华为PCB布线规范

2010-07-14

云计算 Cloud Computing--michael miller

Cloud Computing--michael miller PDF格式 云计算经典权威原版书籍 About the Author Michael Miller is a successful and prolific author. He is known for his casual, easy-to-read writing style and his ability to explain a wide variety of complex topics to an everyday audience. Mr. Miller has written more than 80 nonfiction books over the past two decades, with more than a million copies in print. His books for Que include Absolute Beginner’s Guide to Computer Basics, How Microsoft Windows Vista Works, Making a Living from Your eBay Business, Googlepedia: The Ultimate Google Resource, and Is It Safe? Protecting Your Computer, Your Business, and Yourself Online. You can email Mr. Miller directly at [email protected]. His website is located at www.molehillgroup.com. Dedication To Sherry. Life is a cloud. Acknowledgments Thanks to the usual suspects at Que, including but not limited to Greg Wiegand, Rick Kughen, Seth Kerney, Keith Cline, and technical editor Aaron Ricadela.

2010-06-24

CodeVisionAVR Evaluation V2.04.4a

CodeVisionAVR Evaluation V2.04.4a.exe

2009-10-31

linux内核 0.11版本源码 带中文注释

目录树 下面再给个样例 ├─Makefile │ ├─boot │ bootsect.s │ head.s │ setup.s │ ├─fs │ bitmap.c │ block_dev.c │ buffer.c │ char_dev.c │ exec.c │ fcntl.c │ file_dev.c │ file_table.c │ inode.c │ ioctl.c │ Makefile │ namei.c │ open.c │ pipe.c │ read_write.c │ stat.c │ super.c │ truncate.c │ ├─include │ │ a.out.h │ │ const.h │ │ ctype.h │ │ errno.h │ │ fcntl.h │ │ signal.h │ │ stdarg.h │ │ stddef.h │ │ string.h │ │ termios.h │ │ time.h │ │ unistd.h │ │ utime.h │ │ │ ├─asm │ │ io.h │ │ memory.h │ │ segment.h │ │ system.h │ │ │ ├─linux │ │ config.h │ │ fs.h │ │ hdreg.h │ │ head.h │ │ kernel.h │ │ mm.h │ │ sched.h │ │ sys.h │ │ tty.h │ │ │ └─sys │ stat.h │ times.h │ types.h │ utsname.h │ wait.h │ ├─init │ main.c │ ├─kernel │ │ asm.s │ │ exit.c │ │ fork.c │ │ mktime.c │ │ panic.c │ │ printk.c │ │ sched.c │ │ signal.c │ │ sys.c │ │ system_call.s │ │ vsprintf.c │ │ │ ├─blk_drv │ │ blk.h │ │ floppy.c │ │ hd.c │ │ ll_rw_blk.c │ │ Makefile │ │ ramdisk.c │ │ │ ├─chr_drv │ │ console.c │ │ keyboard.S │ │ Makefile │ │ rs_io.s │ │ serial.c │ │ tty_io.c │ │ tty_ioctl.c │ │ │ └─math │ Makefile │ math_emulate. │ ├─lib │ close.c │ ctype.c │ dup.c │ errno.c │ execve.c │ Makefile │ malloc.c │ open.c │ setsid.c │ string.c │ wait.c │ write.c │ _exit.c │ ├─mm │ Makefile │ memory.c │ page.s │ └─tools build.c 样例 main。c 用sourceinsight软件阅读 很方便 /* * linux/init/main.c * * (C) 1991 Linus Torvalds */ #define __LIBRARY__ // 定义该变量是为了包括定义在unistd.h 中的内嵌汇编代码等信息。 #include // *.h 头文件所在的默认目录是include/,则在代码中就不用明确指明位置。 // 如果不是UNIX 的标准头文件,则需要指明所在的目录,并用双引号括住。 // 标准符号常数与类型文件。定义了各种符号常数和类型,并申明了各种函数。 // 如果定义了__LIBRARY__,则还包括系统调用号和内嵌汇编代码_syscall0()等。 #include // 时间类型头文件。其中最主要定义了tm 结构和一些有关时间的函数原形。 /* * we need this inline - forking from kernel space will result * in NO COPY ON WRITE (!!!), until an execve is executed. This * is no problem, but for the stack. This is handled by not letting * main() use the stack at all after fork(). Thus, no function * calls - which means inline code for fork too, as otherwise we * would use the stack upon exit from 'fork()'. * * Actually only pause and fork are needed inline, so that there * won't be any messing with the stack from main(), but we define * some others too. */ /* * 我们需要下面这些内嵌语句 - 从内核空间创建进程(forking)将导致没有写时复制(COPY ON WRITE)!!! * 直到一个执行execve 调用。这对堆栈可能带来问题。处理的方法是在fork()调用之后不让main()使用 * 任何堆栈。因此就不能有函数调用 - 这意味着fork 也要使用内嵌的代码,否则我们在从fork()退出 * 时就要使用堆栈了。 * 实际上只有pause 和fork 需要使用内嵌方式,以保证从main()中不会弄乱堆栈,但是我们同时还 * 定义了其它一些函数。 */ static inline _syscall0 (int, fork) // 是unistd.h 中的内嵌宏代码。以嵌入汇编的形式调用 // Linux 的系统调用中断0x80。该中断是所有系统调用的 // 入口。该条语句实际上是int fork()创建进程系统调用。 // syscall0 名称中最后的0 表示无参数,1 表示1 个参数。 static inline _syscall0 (int, pause) // int pause()系统调用:暂停进程的执行,直到 // 收到一个信号。 static inline _syscall1 (int, setup, void *, BIOS) // int setup(void * BIOS)系统调用,仅用于 // linux 初始化(仅在这个程序中被调用)。 static inline _syscall0 (int, sync) // int sync()系统调用:更新文件系统。 #include // tty 头文件,定义了有关tty_io,串行通信方面的参数、常数。 #include // 调度程序头文件,定义了任务结构task_struct、第1 个初始任务 // 的数据。还有一些以宏的形式定义的有关描述符参数设置和获取的 // 嵌入式汇编函数程序。 #include // head 头文件,定义了段描述符的简单结构,和几个选择符常量。 #include // 系统头文件。以宏的形式定义了许多有关设置或修改 // 描述符/中断门等的嵌入式汇编子程序。 #include // io 头文件。以宏的嵌入汇编程序形式定义对io 端口操作的函数。 #include // 标准定义头文件。定义了NULL, offsetof(TYPE, MEMBER)。 #include // 标准参数头文件。以宏的形式定义变量参数列表。主要说明了-个 // 类型(va_list)和三个宏(va_start, va_arg 和va_end),vsprintf、 // vprintf、vfprintf。 #include #include // 文件控制头文件。用于文件及其描述符的操作控制常数符号的定义。 #include // 类型头文件。定义了基本的系统数据类型。 #include // 文件系统头文件。定义文件表结构(file,buffer_head,m_inode 等)。 static char printbuf[1024]; // 静态字符串数组。 extern int vsprintf (); // 送格式化输出到一字符串中(在kernel/vsprintf.c,92 行)。 extern void init (void); // 函数原形,初始化(在168 行)。 extern void blk_dev_init (void); // 块设备初始化子程序(kernel/blk_drv/ll_rw_blk.c,157 行) extern void chr_dev_init (void); // 字符设备初始化(kernel/chr_drv/tty_io.c, 347 行) extern void hd_init (void); // 硬盘初始化程序(kernel/blk_drv/hd.c, 343 行) extern void floppy_init (void); // 软驱初始化程序(kernel/blk_drv/floppy.c, 457 行) extern void mem_init (long start, long end); // 内存管理初始化(mm/memory.c, 399 行) extern long rd_init (long mem_start, int length); //虚拟盘初始化(kernel/blk_drv/ramdisk.c,52) extern long kernel_mktime (struct tm *tm); // 建立内核时间(秒)。 extern long startup_time; // 内核启动时间(开机时间)(秒)。 /* * This is set up by the setup-routine at boot-time */ /* * 以下这些数据是由setup.s 程序在引导时间设置的(参见第2 章2.3.1 节中的表2.1)。 */ #define EXT_MEM_K (*(unsigned short *)0x90002) // 1M 以后的扩展内存大小(KB)。 #define DRIVE_INFO (*(struct drive_info *)0x90080) // 硬盘参数表基址。 #define ORIG_ROOT_DEV (*(unsigned short *)0x901FC) // 根文件系统所在设备号。 /* * Yeah, yeah, it's ugly, but I cannot find how to do this correctly * and this seems to work. I anybody has more info on the real-time * clock I'd be interested. Most of this was trial and error, and some * bios-listing reading. Urghh. */ /* * 是啊,是啊,下面这段程序很差劲,但我不知道如何正确地实现,而且好象它还能运行。如果有 * 关于实时时钟更多的资料,那我很感兴趣。这些都是试探出来的,以及看了一些bios 程序,呵! */ #define CMOS_READ(addr) ({ \ // 这段宏读取CMOS 实时时钟信息。 outb_p (0x80 | addr, 0x70); \ // 0x70 是写端口号,0x80|addr 是要读取的CMOS 内存地址。 inb_p (0x71); \ // 0x71 是读端口号。 } ) #define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10) // 将BCD 码转换成数字。 static void time_init (void) // 该子程序取CMOS 时钟,并设置开机时间??startup_time(秒)。 { struct tm time; do { time.tm_sec = CMOS_READ (0); // 参见后面CMOS 内存列表。 time.tm_min = CMOS_READ (2); time.tm_hour = CMOS_READ (4); time.tm_mday = CMOS_READ (7); time.tm_mon = CMOS_READ (8); time.tm_year = CMOS_READ (9); } while (time.tm_sec != CMOS_READ (0)); BCD_TO_BIN (time.tm_sec); BCD_TO_BIN (time.tm_min); BCD_TO_BIN (time.tm_hour); BCD_TO_BIN (time.tm_mday); BCD_TO_BIN (time.tm_mon); BCD_TO_BIN (time.tm_year); time.tm_mon--; startup_time = kernel_mktime (&time); } static long memory_end = 0; // 机器具有的内存(字节数)。 static long buffer_memory_end = 0; // 高速缓冲区末端地址。 static long main_memory_start = 0; // 主内存(将用于分页)开始的位置。 struct drive_info { char dummy[32]; } drive_info; // 用于存放硬盘参数表信息。 void main (void) /* This really IS void, no error here. */ { /* The startup routine assumes (well, ...) this */ /* 这里确实是void,并没错。在startup 程序(head.s)中就是这样假设的。 */ // 参见head.s 程序第136 行开始的几行代码。 /* * Interrupts are still disabled. Do necessary setups, then * enable them */ /* * 此时中断仍被禁止着,做完必要的设置后就将其开启。 */ // 下面这段代码用于保存: // 根设备号 ??ROOT_DEV; 高速缓存末端地址??buffer_memory_end; // 机器内存数??memory_end;主内存开始地址 ??main_memory_start; ROOT_DEV = ORIG_ROOT_DEV; drive_info = DRIVE_INFO; memory_end = (1 << 20) + (EXT_MEM_K < 16 * 1024 * 1024) // 如果内存超过16Mb,则按16Mb 计。 memory_end = 16 * 1024 * 1024; if (memory_end > 12 * 1024 * 1024) // 如果内存>12Mb,则设置缓冲区末端=4Mb buffer_memory_end = 4 * 1024 * 1024; else if (memory_end > 6 * 1024 * 1024) // 否则如果内存>6Mb,则设置缓冲区末端=2Mb buffer_memory_end = 2 * 1024 * 1024; else buffer_memory_end = 1 * 1024 * 1024; // 否则则设置缓冲区末端=1Mb main_memory_start = buffer_memory_end; // 主内存起始位置=缓冲区末端; #ifdef RAMDISK // 如果定义了虚拟盘,则主内存将减少。 main_memory_start += rd_init (main_memory_start, RAMDISK * 1024); #endif // 以下是内核进行所有方面的初始化工作。阅读时最好跟着调用的程序深入进去看,实在看 // 不下去了,就先放一放,看下一个初始化调用 -- 这是经验之谈?。 mem_init (main_memory_start, memory_end); trap_init (); // 陷阱门(硬件中断向量)初始化。(kernel/traps.c,181 行) blk_dev_init (); // 块设备初始化。 (kernel/blk_dev/ll_rw_blk.c,157 行) chr_dev_init (); // 字符设备初始化。 (kernel/chr_dev/tty_io.c,347 行) tty_init (); // tty 初始化。 (kernel/chr_dev/tty_io.c,105 行) time_init (); // 设置开机启动时间??startup_time(见76 行)。 sched_init (); // 调度程序初始化(加载了任务0 的tr, ldtr) (kernel/sched.c,385) buffer_init (buffer_memory_end); // 缓冲管理初始化,建内存链表等。(fs/buffer.c,348) hd_init (); // 硬盘初始化。 (kernel/blk_dev/hd.c,343 行) floppy_init (); // 软驱初始化。 (kernel/blk_dev/floppy.c,457 行) sti (); // 所有初始化工作都做完了,开启中断。 // 下面过程通过在堆栈中设置的参数,利用中断返回指令切换到任务0。 move_to_user_mode (); // 移到用户模式。 (include/asm/system.h,第1 行) if (!fork ()) { /* we count on this going ok */ init (); } /* * NOTE!! For any other task 'pause()' would mean we have to get a * signal to awaken, but task0 is the sole exception (see 'schedule()') * as task 0 gets activated at every idle moment (when no other tasks * can run). For task0 'pause()' just means we go check if some other * task can run, and if not we return here. */ /* 注意!! 对于任何其它的任务,'pause()'将意味着我们必须等待收到一个信号才会返 * 回就绪运行态,但任务0(task0)是唯一的意外情况(参见'schedule()'),因为任务0 在 * 任何空闲时间里都会被激活(当没有其它任务在运行时),因此对于任务0'pause()'仅意味着 * 我们返回来查看是否有其它任务可以运行,如果没有的话我们就回到这里,一直循环执行'pause()'。 */ for (;;) pause (); } static int printf (const char *fmt, ...) // 产生格式化信息并输出到标准输出设备stdout(1),这里是指屏幕上显示。参数'*fmt'指定输出将 // 采用的格式,参见各种标准C 语言书籍。该子程序正好是vsprintf 如何使用的一个例子。 // 该程序使用vsprintf()将格式化的字符串放入printbuf 缓冲区,然后用write()将缓冲区的内容 // 输出到标准设备(1--stdout)。 { va_list args; int i; va_start (args, fmt); write (1, printbuf, i = vsprintf (printbuf, fmt, args)); va_end (args); return i; } static char *argv_rc[] = { "/bin/sh", NULL}; // 调用执行程序时参数的字符串数组。 static char *envp_rc[] = { "HOME=/", NULL}; // 调用执行程序时的环境字符串数组。 static char *argv[] = { "-/bin/sh", NULL}; // 同上。 static char *envp[] = { "HOME=/usr/root", NULL}; void init (void) { int pid, i; // 读取硬盘参数包括分区表信息并建立虚拟盘和安装根文件系统设备。 // 该函数是在25 行上的宏定义的,对应函数是sys_setup(),在kernel/blk_drv/hd.c,71 行。 setup ((void *) &drive_info); (void) open ("/dev/tty0", O_RDWR, 0); // 用读写访问方式打开设备“/dev/tty0”, // 这里对应终端控制台。 // 返回的句柄号0 -- stdin 标准输入设备。 (void) dup (0); // 复制句柄,产生句柄1 号 -- stdout 标准输出设备。 (void) dup (0); // 复制句柄,产生句柄2 号 -- stderr 标准出错输出设备。 printf ("%d buffers = %d bytes buffer space\n\r", NR_BUFFERS, NR_BUFFERS * BLOCK_SIZE); // 打印缓冲区块数和总字节数,每块1024 字节。 printf ("Free mem: %d bytes\n\r", memory_end - main_memory_start); //空闲内存字节数。 // 下面fork()用于创建一个子进程(子任务)。对于被创建的子进程,fork()将返回0 值, // 对于原(父进程)将返回子进程的进程号。所以180-184 句是子进程执行的内容。该子进程 // 关闭了句柄0(stdin),以只读方式打开/etc/rc 文件,并执行/bin/sh 程序,所带参数和 // 环境变量分别由argv_rc 和envp_rc 数组给出。参见后面的描述。 if (!(pid = fork ())) { close (0); if (open ("/etc/rc", O_RDONLY, 0)) _exit (1); // 如果打开文件失败,则退出(/lib/_exit.c,10)。 execve ("/bin/sh", argv_rc, envp_rc); // 装入/bin/sh 程序并执行。 _exit (2); // 若execve()执行失败则退出(出错码2,“文件或目录不存在”)。 } // 下面是父进程执行的语句。wait()是等待子进程停止或终止,其返回值应是子进程的进程号(pid)。 // 这三句的作用是父进程等待子进程的结束。&i 是存放返回状态信息的位置。如果wait()返回值不 // 等于子进程号,则继续等待。 if (pid > 0) while (pid != wait (&i)) /* nothing */ ; // 如果执行到这里,说明刚创建的子进程的执行已停止或终止了。下面循环中首先再创建一个子进程, // 如果出错,则显示“初始化程序创建子进程失败”的信息并继续执行。对于所创建的子进程关闭所有 // 以前还遗留的句柄(stdin, stdout, stderr),新创建一个会话并设置进程组号,然后重新打开 // /dev/tty0 作为stdin,并复制成stdout 和stderr。再次执行系统解释程序/bin/sh。但这次执行所 // 选用的参数和环境数组另选了一套(见上面165-167 行)。然后父进程再次运行wait()等待。如果 // 子进程又停止了执行,则在标准输出上显示出错信息“子进程pid 停止了运行,返回码是i”,然后 // 继续重试下去…,形成“大”死循环。 while (1) { if ((pid = fork ()) < 0) { printf ("Fork failed in init\r\n"); continue; } if (!pid) { close (0); close (1); close (2); setsid (); (void) open ("/dev/tty0", O_RDWR, 0); (void) dup (0); (void) dup (0); _exit (execve ("/bin/sh", argv, envp)); } while (1) if (pid == wait (&i)) break; printf ("\n\rchild %d died with code %04x\n\r", pid, i); sync (); } _exit (0); /* NOTE! _exit, not exit() */ }

2009-08-31

The Linux Kernel Module Programming Guide2.6.pdf

The Linux Kernel Module Programming Guide2.6.pdf 纯英文

2009-07-29

Building.Embedded.Linux.Systems.Aug.2008.pdf

Building.Embedded.Linux.Systems.Aug.2008.pdf 纯英文版

2009-07-29

PDF破解密码(免注册)

pdf文件密码 使到文件可以被复制修改 非常好用的 破解时间很快

2009-07-27

S3C44B0X中文数据手册1~17

缺省15 似乎互联网上都没有出现过15的 S3C44B0X中文数据手册1-S3C44B0X概述.pdf S3C44B0X中文数据手册2-ARM处理器工作模式.pdf S3C44B0X中文数据手册3-ARM微处理器的指令系统.pdf S3C44B0X中文数据手册4-存储器控制器.pdf S3C44B0X中文数据手册5-DMA.pdf S3C44B0X中文数据手册6-处理器Wrapper和总线优.pdf S3C44B0X中文数据手册7-DMA.pdf S3C44B0X中文数据手册8-IO端口.pdf S3C44B0X中文数据手册9-PWM定时器.pdf S3C44B0X中文数据手册10-UART串行口.pdf S3C44B0X中文数据手册11-中断控制器.pdf S3C44B0X中文数据手册12-LCD控制器.pdf S3C44B0X中文数据手册13-AD转换器.pdf S3C44B0X中文数据手册14-RTC.pdf S3C44B0X中文数据手册16-IIC总线接口.pdf S3C44B0X中文数据手册17-IIS总线接口.pdf

2009-07-15

RT1602C详细资料

自己整合网络上的资源制作的,内容包过:1产品规格 2引脚说明 3内置字符表 4基本控制指令 5内部显示地址 6和单片机AT89C51交互 7样本程序1例

2009-05-31

DM642芯片手册,外设,ccs教程等

DM642的芯片资料 各种外设资料 和ccs软件的教程

2009-05-27

魔方虚拟软件(1~20)

支持2阶到20阶的魔方 操作极容易上手 可以保存数据关电脑明天再转也可以

2009-05-27

现代电子技术实践基础教程

第一章 电子实践常识.doc 第七章 可靠性技术.doc 第三章 印制电路板设计.doc 第九章 PROTEL 99 SE.doc 第二章 元器件筛选技术.doc 第五章 系统组装技术.doc 第八章 电子产品认证.doc 第六章 测量与调试技术.doc 第四章 板上组装技术.doc

2009-04-17

谭浩强C语言全书word版

谭浩强C语言全书word版 总共十本内容详细 精心排版

2009-04-11

考研英语大纲词汇中英文.doc

根据新大纲制作,共5495单词 精心表格排版 电脑前照样背单词

2009-04-11

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除