艺术的追求从编程开始

C/C++/UNIX/PYTHON/ALGORITHM

导航

2012年7月4日

将char转成bit,文件读写

摘要: 好久不写代码,一段将bmp写到mif的小程序花了我好几个小时。以后要多练习啊。 1 #include <string.h> 2 #include <stdio.h> 3 #include <math.h> 4 5 6 void main(){ 7 char str[3]; 8 char pos_str[5]; 9 10 FILE *fp_read;11 fp_read = fopen("pattern_mem.bmp","r");12 13 FILE *fp_write;14 fp_write = fopen(&quo 阅读全文

posted @ 2012-07-04 21:35 Rambo.Wang 阅读(1904) 评论(0) 推荐(0) 编辑

2012年5月14日

linux字符设备驱动程序怎么写

摘要: 摘要:linux设备驱动程序第三版第三章笔记1.scull:simple character utility for loading localities.2.scull0-scull3: 4个global and persistent设备,映射到的物理内存区是不会消失的。 scullpipe0-scullpipe3:4个FIFO设备,一个进程读一个进程写。3.主次编号: 3.1 major number标志了设备相联系的driver。 minor number用来决定引用了哪个设备。 3.2 设备编号内部表示: dev_t类型<linux/types.h>中含有设备编号 获得d. 阅读全文

posted @ 2012-05-14 21:09 Rambo.Wang 阅读(1393) 评论(0) 推荐(0) 编辑

2012年5月13日

MIPS 架构

摘要: 1.MIPS (Microprocessor without Interlocked Pipeline Stages):(1) Define a control register set as well as the instruction set.(2) RISC(3) Features about assembly language: a) Integer: there are 32 integer registers b) Floating point : has 32 floating-point, two registers paired for double precision.. 阅读全文

posted @ 2012-05-13 23:40 Rambo.Wang 阅读(580) 评论(0) 推荐(0) 编辑

2012年5月12日

VIM GDB操作

摘要: 1.按F6打开键映射(在~/.vim/macros/gdb_mapping.vim中修改)2.空格打开command_line窗口 输入:cd ** file nachos回车,就可以看到调试窗口了3.ctrl+B设置断点 ctrl+N //next R //run S //step C //continue4.跟踪变量: :bel 20vsplit gdb-variables //分割出gdb-variables窗口 然后用”v“命令选中变量i,按”CTRL-P“命令,把变量i加入到监视窗口 输入下面的命令,把变量*r输入到变量窗口: c... 阅读全文

posted @ 2012-05-12 19:35 Rambo.Wang 阅读(381) 评论(0) 推荐(0) 编辑

2012年5月2日

LINUX内核符号表

摘要: 1.内核导出符号用EXPORT_SYMBOL()或者EXPORT_SYMBOL_GPL()导出。2.系统内核符号导出记录在/proc/kallsyms文件中,我们可以使用cat /proc/kallsyms查看当前环境下的导出内核符号。3.示例:(1)导出符号的内核模块(2)导入符号的内核模块 阅读全文

posted @ 2012-05-02 15:42 Rambo.Wang 阅读(2104) 评论(0) 推荐(0) 编辑

2012年5月1日

如何写makefile

摘要: 1.一个简单的例子:TOPDIR = ../include $(TOPDIR)Rule.makEXTRA_LIB +=EXEC = $(INSTALL_DIR)/helloOBJS = hello.oall:$(EXEC)$(EXEC):$(OBJS) $(CC) $(LDFLAGS) -o $@ $(OBJS) $(EXTRA_LIBS)install: $(EXP_INSTALL) $(EXEC) $(INSTALL_DIR)clean: -rm -f $(EXEC) *.elf *.gdb *.o好了,其中:CC 指明编译器的宏EXEC表明生成的执行文件名称的宏OBJS 目标文件列... 阅读全文

posted @ 2012-05-01 16:28 Rambo.Wang 阅读(383) 评论(0) 推荐(0) 编辑

linux如何添加内核模块

摘要: 1.编写模块代码: 简单例子:#include<linux/kernel.h>#include<linux/module.h>#Inlcude<linux/init.h>static int __init hello_init(void){ printk(KERN_INFO "Hello world\n"); return 0;}static void __exit hello_exit(void);{ printk(KERN_INFO "Goodbye world\n");}module_init(hello_ini 阅读全文

posted @ 2012-05-01 15:53 Rambo.Wang 阅读(707) 评论(0) 推荐(0) 编辑

2012年4月26日

Notebook of A Road Map Through Nachos

摘要: 1.MIPS(microprocessor with Interlocked Pipeline Stages): 1) Define a control register set as well as the instruction set. 2) RISC 3)About the assembly language: a. Integer: 32bit integer registers. b. Floating point: has 32bit floating-point, two registers paird for double precision numbers... 阅读全文

posted @ 2012-04-26 16:33 Rambo.Wang 阅读(181) 评论(0) 推荐(0) 编辑

2012年4月24日

老林课上笔记

摘要: firmware: 1.系统初始化 2.响应主机请求包括:1.描述表(VID,PID) 2.USB控制程序 3.固件执行程序固件中最核心部分为:中断服务程序。 初始化以后就不断等待中断。RS 232 & UART:不同:电平的不同,逻辑上来看232LSB先传,1.232异步传输如何保持一致性? 没有数据的时候,保持高电平,在start的时候拉底电平,开始传输数据帧,8位宽度,没有校验位。 波特率设定,决定每一位的宽度。 阅读全文

posted @ 2012-04-24 17:51 Rambo.Wang 阅读(120) 评论(0) 推荐(0) 编辑

2012年4月21日

回顾一下今天VIM历程,加深印象,以免忘记!

摘要: 1.在VIM上安装GDB编译环境: 安装方法:详情可以见前面那个帖子。 使用方法:按F7打开GDB键映射,再按空格打开调试窗口。2.常用命令: %调到配对括号 [[跳到代码块开头 gD跳到局部变量定义处 ‘’跳到光标上次停靠地方 mx设置书签 ‘x跳到书签3.语法高亮:现在还不明白怎么把背景调成黑色。先用着吧。4.Ctags使用: 先在最上层目录使用命令ctags -R自动生成一个tags文件。 再在vim中运行命令:set tags=/home/bubble/nachos/code/tags将tags文件加入到vim中来(也可以将这句话放到~/.vimrc中) ctrl... 阅读全文

posted @ 2012-04-21 22:18 Rambo.Wang 阅读(407) 评论(0) 推荐(0) 编辑