linux 0.11 内核学习 floppy.c,驱动你的软盘
/*
* linux/kernel/floppy.c
*
* (C) 1991 Linus Torvalds
*/
/*
* 02.12.91 - Changed to static variables to indicate need for reset
* and recalibrate. This makes some things easier (output_byte reset
* checking etc), and means less interrupt jumping in case of errors,
* so the code is hopefully easier to understand.
*/
/*
* This file is certainly a mess. I've tried my best to get it working,
* but I don't like programming floppies, and I have only one anyway.
* Urgel. I should check for more errors, and do more graceful error
* recovery. Seems there are problems with several drives. I've tried to
* correct them. No promises.
*/
/*
* As with hd.c, all routines within this file can (and will) be called
* by interrupts, so extreme caution is needed. A hardware interrupt
* handler may not sleep, or a kernel panic will happen. Thus I cannot
* call "floppy-on" directly, but have to set a special timer interrupt
* etc.
*
* Also, I'm not certain this works on more than 1 floppy. Bugs may
* abund.
*/
#include <linux/sched.h>
#include <linux/fs.h>
#include <linux/kernel.h>
#include <linux/fdreg.h> // 软驱头文件,其中包含软驱的常用函数的定义
#include <asm/system.h>
#include <asm/io.h>
#include <asm/segment.h>
#define MAJOR_NR 2 // 软驱主设备号
#include "blk.h"
/* 全局标志变量 */
static int recalibrate = 0; // 需要重新校正
static int reset = 0; // 需要重新置位
static int seek = 0; // 寻道
extern unsigned char current_DOR; // 在文件sched.c中定义
#define immoutb_p(val,port) \ // 字节val直接输出到port
__asm__("outb %0,%1\n\tjmp 1f\n1:\tjmp 1f\n1:"::"a" ((char) (val)),"i" (port))
#define TYPE(x) ((x)>>2) // 软驱类型,2--1.2MB,7--1.44MB
#define DRIVE(x) ((x)&0x03) // 软驱序列号0-3对应A-D
/*
* Note that MAX_ERRORS=8
相关文档:
一:前言
最近在研究android的sensor driver,主要是E-compass,其中用到了Linux input子系统.在网上也看了很多这方面的资料,感觉还是这篇分析的比较细致透彻,因此转载一下以便自己学习,同时和大家分享!
(这篇博客主要是以键盘驱动为例的,不过讲解的是Linux Input Subsystem,可以仔细的研究一下!)
键盘驱动将检 ......
Boss说,要看OpenGL,看了快一个月,总算出了个像样的东西,用C写了个3D迷宫,
虽然只有350行
代码,不过边学边写,足足写了一周时间,还是小有成就感的,活活活!
&n ......
我的系统是redhat as5 建议大家完全安装,以免安装时缺少相关的编译器等等。
一、安装mysql(mysql-5.0.21.tar.gz)
# tar zxf mysql-5.0.21.tar.gz
# cd mysql-5.0.21
#./configure --prefix=/usr/local/mysql --sysconfdir=/etc --localstatedir=/var/lib/mysql/
说明:
#prefix=/usr/lo ......
利用socket编写windows和linux通讯程序
socket编程大家都很熟悉,我在这里就不再罗嗦了。直接切入正题。该程序分两部分,server端和client端(谁都知道)。其中server端采用windows平台,那linux平台当然是client端了。
这里是server端程序:
/**********************************/
/* it work ......
Kscope是Linux下的一款类似于SourceInsight工具,下面将其安装过程总结如下:
1.先下载kscope
kscope最新安装版本kscope-1.6.2.tar.gz
http://download.chinaunix.net/download/0006000/5469.shtml
按照说明#./configure
#make
&nb ......