To be continued...
第8章 UNIX系统接口
#include <stdio.h>
#include <fcntl.h>
#include "syscalls.h"
#defien PERMS 0666
void error(char *, ...);
/* cp函数: 将 f1 复制到 f2 */
int main(int argc, char *argv[])
{
int f1, f2, n;
char buf[BUFSIZ];
if (argc != 3)
error("Usage: c from to");
if ((f1 = open(argv[1], O_RDONLY, 0)) == -1)
error("cp: can't open %s", argv[1]);
if ((f2 = creat(argv[2], PERMS)) == -1)
error("cp: can't create %s, mode %03o", argv[2], PERMS);
while ((n = read(f1, buf, BUFSIZ)) > 0)
if (write(f2, buf, n) != n)
error("cp: write error on file %s", argv[2]);
&nb ......
NandFlash系列之二:S3C2410读写Nand Flash分析
2009年12月09日 星期三 09:06
一、结构分析
S3C2410处理器集成了8位NandFlash控制器。目前市场上常见的8位NandFlash有三星公司的k9f1208、k9f1g08、k9f2g08等。k9f1208、k9f1g08、k9f2g08的数据页大小分别为512Byte、2kByte、2kByte。它们在寻址方式上有一定差异,所以程序代码并不通用。本文以S3C2410处理器和k9f1208系统为例,讲述NandFlash的读写方法。
NandFlash的数据是以bit 的方式保存在memory cell里的,一般来说,一个cell 中只能存储一个bit,这些cell 以8 个或者16 个为单位,连成bit line,形成所谓的byte(x8)/word(x16),这就是NAND Device 的位宽。这些Line 组成Page, page 再组织形成一个Block。k9f1208的相关数据如下:
1block=32page;1page=528byte=512byte(Main Area)+16byte(Spare Area)。
总容量为=4096(block数量)*32(page/block)*512(byte/page)=64Mbyte
NandFlash以页为单位读写数据,而以块为单位擦除数据。按照k9f1208的组织方式可以分四类地址: Column Address、halfpage pointer、Page Address 、Block Address。A[0:25]表示数据在64M空间中的地址。
Column Address表示数据在半页中 ......
NandFlash系列之二:S3C2410读写Nand Flash分析
2009年12月09日 星期三 09:06
一、结构分析
S3C2410处理器集成了8位NandFlash控制器。目前市场上常见的8位NandFlash有三星公司的k9f1208、k9f1g08、k9f2g08等。k9f1208、k9f1g08、k9f2g08的数据页大小分别为512Byte、2kByte、2kByte。它们在寻址方式上有一定差异,所以程序代码并不通用。本文以S3C2410处理器和k9f1208系统为例,讲述NandFlash的读写方法。
NandFlash的数据是以bit 的方式保存在memory cell里的,一般来说,一个cell 中只能存储一个bit,这些cell 以8 个或者16 个为单位,连成bit line,形成所谓的byte(x8)/word(x16),这就是NAND Device 的位宽。这些Line 组成Page, page 再组织形成一个Block。k9f1208的相关数据如下:
1block=32page;1page=528byte=512byte(Main Area)+16byte(Spare Area)。
总容量为=4096(block数量)*32(page/block)*512(byte/page)=64Mbyte
NandFlash以页为单位读写数据,而以块为单位擦除数据。按照k9f1208的组织方式可以分四类地址: Column Address、halfpage pointer、Page Address 、Block Address。A[0:25]表示数据在64M空间中的地址。
Column Address表示数据在半页中 ......
#include <windows.h>
int IsGB(PTSTR pText);
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static TCHAR szText[] = {TEXT ("i服,了。uy")} ;
PTSTR pText;
int i;
unsigned char sqChar[20];
pText=szText;
while (*pText != '\0')
{
i=IsGB(pText);
switch(i)
{
case 0:
pText++;
MessageBox (NULL, TEXT ("发现数字、英文字符或英文标点"), TEXT ("Hello"), 0);
break;
case 1:
pText++;
pText++;
MessageBox (NULL, TEXT ("发现全角字符"), TEXT ("Hello"), 0);
break;
case 2:
pText++;
pText++;
MessageBox (NULL, TEXT ("发现汉字"), TEXT ("Hello"), 0);
break;
& ......
#include <stdio.h>
#include <stdlib.h> //use malloc, free
#include <string.h> //use memset
#include <ctype.h> //use isdigit
#define ERROR_ILLEGAL_CHAR 1 //define error illegal character as 1
#define ERROR_NUMBERS_DIF 2 //define error numbers is not the same in different line as 2
#define ERROR_FILE_ERROR 3 //define error file error as 3
typedef struct _node{
int num;
struct _node *next;
}node;
node *head = NULL;
void insert(int num)
{
if (NULL == head)
{
head = (node*)malloc(sizeof(node));
(*head).num = num;
(*head).next = NULL;
}
else
{
node* p = head;
while (NULL != p->next) //move to end
{
p = p->next;
}
p->next = (node*)malloc(sizeof(node));
p = p->next;
(*p).num = num;
(*p).next = NULL;
}
}
void output(int rows, int cols)
{
node *p = head;
if (NULL == p)
return;
for (int i=0; i<rows; i++)
{
for (int j=0; j<cols; j++)
{
printf("%-4d", p->num);
p = p-> ......
1、从N个数中选出n个最大的数,写出思路和实现。
先读入n个,并且排序,队列,就是有序的队列。然后再一个个读,比最大的那个大的时候就FIFO。
2、写出一个c/s通讯程序,要求服务器端用非阻塞模式。
不让抄书?不让上网?直接拽一句“你Y当我man文档啊?”
3、TCP/UDP的异同。
确认机制,不知道还要问什么,顺便扯扯TCP和UDP的包头?
4、32位平台上,有个2G的文件,全是4字节整数,整数的最大值不超过8亿,这些整数重复最多不超过2次,给你条件:200M可用内存,5G硬盘空间,要把这些整数排序,不排除重复的数据。
KMP+atol行不?
5、什么是精灵程序,写出一个精灵程序的实现。
直接反问知道什么是Daemon不?
6、进程间通讯的方式。。
你想要什么?Socket?pipe?内存?文件?我都用过XML进行进程间通信。
7、2000!末尾有几个0(智力题). ......
1、从N个数中选出n个最大的数,写出思路和实现。
先读入n个,并且排序,队列,就是有序的队列。然后再一个个读,比最大的那个大的时候就FIFO。
2、写出一个c/s通讯程序,要求服务器端用非阻塞模式。
不让抄书?不让上网?直接拽一句“你Y当我man文档啊?”
3、TCP/UDP的异同。
确认机制,不知道还要问什么,顺便扯扯TCP和UDP的包头?
4、32位平台上,有个2G的文件,全是4字节整数,整数的最大值不超过8亿,这些整数重复最多不超过2次,给你条件:200M可用内存,5G硬盘空间,要把这些整数排序,不排除重复的数据。
KMP+atol行不?
5、什么是精灵程序,写出一个精灵程序的实现。
直接反问知道什么是Daemon不?
6、进程间通讯的方式。。
你想要什么?Socket?pipe?内存?文件?我都用过XML进行进程间通信。
7、2000!末尾有几个0(智力题). ......
#apt-get install gcc (编译器)
#apt-get install gdb (调试)
#apt-get install libc6-dev (开发库)
如果没有开发库,gcc的时候就会错误
gcc h.c
h.c: In function ‘main’:
h.c:1: warning: incompatible implicit declaration of built-in function ‘printf ’
/usr/bin/ld: crt1.o: No such file: No such file or directory
collect2: ld returned 1 exit status
安装后就没有问题了:
gcc h.c
h.c: In function ‘main’:
h.c:1: warning: incompatible implicit declaration of built-in function ‘printf
gcc -o hello hello.c
hello.c: In function ‘main’:
hello.c:2: warning: incompat ......
#apt-get install gcc (编译器)
#apt-get install gdb (调试)
#apt-get install libc6-dev (开发库)
如果没有开发库,gcc的时候就会错误
gcc h.c
h.c: In function ‘main’:
h.c:1: warning: incompatible implicit declaration of built-in function ‘printf ’
/usr/bin/ld: crt1.o: No such file: No such file or directory
collect2: ld returned 1 exit status
安装后就没有问题了:
gcc h.c
h.c: In function ‘main’:
h.c:1: warning: incompatible implicit declaration of built-in function ‘printf
gcc -o hello hello.c
hello.c: In function ‘main’:
hello.c:2: warning: incompat ......