亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? floppy.c

?? LINUX1.0源代碼,代碼條理清晰
?? C
?? 第 1 頁 / 共 3 頁
字號:
/*
 *  linux/kernel/floppy.c
 *
 *  Copyright (C) 1991, 1992  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.
 */

/*
 * 28.02.92 - made track-buffering routines, based on the routines written
 * by entropy@wintermute.wpi.edu (Lawrence Foard). Linus.
 */

/*
 * Automatic floppy-detection and formatting written by Werner Almesberger
 * (almesber@nessie.cs.id.ethz.ch), who also corrected some problems with
 * the floppy-change signal detection.
 */

/*
 * 1992/7/22 -- Hennus Bergman: Added better error reporting, fixed 
 * FDC data overrun bug, added some preliminary stuff for vertical
 * recording support.
 *
 * 1992/9/17: Added DMA allocation & DMA functions. -- hhb.
 *
 * TODO: Errors are still not counted properly.
 */

/* 1992/9/20
 * Modifications for ``Sector Shifting'' by Rob Hooft (hooft@chem.ruu.nl)
 * modelled after the freeware MS/DOS program fdformat/88 V1.8 by 
 * Christoph H. Hochst\"atter.
 * I have fixed the shift values to the ones I always use. Maybe a new
 * ioctl() should be created to be able to modify them.
 * There is a bug in the driver that makes it impossible to format a
 * floppy as the first thing after bootup.
 */

/*
 * 1993/4/29 -- Linus -- cleaned up the timer handling in the kernel, and
 * this helped the floppy driver as well. Much cleaner, and still seems to
 * work.
 */

#define REALLY_SLOW_IO
#define FLOPPY_IRQ 6
#define FLOPPY_DMA 2

#include <linux/sched.h>
#include <linux/fs.h>
#include <linux/kernel.h>
#include <linux/timer.h>
#include <linux/fdreg.h>
#include <linux/fd.h>
#include <linux/errno.h>

#include <asm/dma.h>
#include <asm/system.h>
#include <asm/io.h>
#include <asm/segment.h>

#define MAJOR_NR FLOPPY_MAJOR
#include "blk.h"

static unsigned int changed_floppies = 0, fake_change = 0;

static int initial_reset_flag = 0;
static int need_configure = 1;		/* for 82077 */
static int recalibrate = 0;
static int reset = 0;
static int recover = 0; /* recalibrate immediately after resetting */
static int seek = 0;

static unsigned char current_DOR = 0x0C;
static unsigned char running = 0;

#define TYPE(x) ((x)>>2)
#define DRIVE(x) ((x)&0x03)

/*
 * Note that MAX_ERRORS=X doesn't imply that we retry every bad read
 * max X times - some types of errors increase the errorcount by 2 or
 * even 3, so we might actually retry only X/2 times before giving up.
 */
#define MAX_ERRORS 12

/*
 * Maximum disk size (in kilobytes). This default is used whenever the
 * current disk size is unknown.
 */
#define MAX_DISK_SIZE 1440

/*
 * Maximum number of sectors in a track buffer. Track buffering is disabled
 * if tracks are bigger.
 */
#define MAX_BUFFER_SECTORS 18

/*
 * The DMA channel used by the floppy controller cannot access data at
 * addresses >= 16MB
 *
 * Went back to the 1MB limit, as some people had problems with the floppy
 * driver otherwise. It doesn't matter much for performance anyway, as most
 * floppy accesses go through the track buffer.
 */
#define LAST_DMA_ADDR	(0x100000 - BLOCK_SIZE)

/*
 * globals used by 'result()'
 */
#define MAX_REPLIES 7
static unsigned char reply_buffer[MAX_REPLIES];
#define ST0 (reply_buffer[0])
#define ST1 (reply_buffer[1])
#define ST2 (reply_buffer[2])
#define ST3 (reply_buffer[3])

/*
 * This struct defines the different floppy types.
 *
 * The 'stretch' tells if the tracks need to be doubled for some
 * types (ie 360kB diskette in 1.2MB drive etc). Others should
 * be self-explanatory.
 */
static struct floppy_struct floppy_type[] = {
	{    0, 0,0, 0,0,0x00,0x00,0x00,0x00,NULL },	/* no testing */
	{  720, 9,2,40,0,0x2A,0x02,0xDF,0x50,NULL },	/* 360kB PC diskettes */
	{ 2400,15,2,80,0,0x1B,0x00,0xDF,0x54,NULL },	/* 1.2 MB AT-diskettes */
	{  720, 9,2,40,1,0x2A,0x02,0xDF,0x50,NULL },	/* 360kB in 720kB drive */
	{ 1440, 9,2,80,0,0x2A,0x02,0xDF,0x50,NULL },	/* 3.5" 720kB diskette */
	{  720, 9,2,40,1,0x23,0x01,0xDF,0x50,NULL },	/* 360kB in 1.2MB drive */
	{ 1440, 9,2,80,0,0x23,0x01,0xDF,0x50,NULL },	/* 720kB in 1.2MB drive */
	{ 2880,18,2,80,0,0x1B,0x00,0xCF,0x6C,NULL },	/* 1.44MB diskette */
};

/*
 * Auto-detection. Each drive type has a pair of formats which are
 * used in succession to try to read the disk. If the FDC cannot lock onto
 * the disk, the next format is tried. This uses the variable 'probing'.
 */
static struct floppy_struct floppy_types[] = {
	{  720, 9,2,40,0,0x2A,0x02,0xDF,0x50,"360k/PC" }, /* 360kB PC diskettes */
	{  720, 9,2,40,0,0x2A,0x02,0xDF,0x50,"360k/PC" }, /* 360kB PC diskettes */
	{ 2400,15,2,80,0,0x1B,0x00,0xDF,0x54,"1.2M" },	  /* 1.2 MB AT-diskettes */
	{  720, 9,2,40,1,0x23,0x01,0xDF,0x50,"360k/AT" }, /* 360kB in 1.2MB drive */
	{ 1440, 9,2,80,0,0x2A,0x02,0xDF,0x50,"720k" },	  /* 3.5" 720kB diskette */
	{ 1440, 9,2,80,0,0x2A,0x02,0xDF,0x50,"720k" },	  /* 3.5" 720kB diskette */
	{ 2880,18,2,80,0,0x1B,0x00,0xCF,0x6C,"1.44M" },	  /* 1.44MB diskette */
	{ 1440, 9,2,80,0,0x2A,0x02,0xDF,0x50,"720k/AT" }, /* 3.5" 720kB diskette */
};

/* Auto-detection: Disk type used until the next media change occurs. */
struct floppy_struct *current_type[4] = { NULL, NULL, NULL, NULL };

/* This type is tried first. */
struct floppy_struct *base_type[4];

/*
 * User-provided type information. current_type points to
 * the respective entry of this array.
 */
struct floppy_struct user_params[4];

static int floppy_sizes[] ={
	MAX_DISK_SIZE, MAX_DISK_SIZE, MAX_DISK_SIZE, MAX_DISK_SIZE,
	 360, 360 ,360, 360,
	1200,1200,1200,1200,
	 360, 360, 360, 360,
	 720, 720, 720, 720,
	 360, 360, 360, 360,
	 720, 720, 720, 720,
	1440,1440,1440,1440
};

/*
 * The driver is trying to determine the correct media format
 * while probing is set. rw_interrupt() clears it after a
 * successful access.
 */
static int probing = 0;

/*
 * (User-provided) media information is _not_ discarded after a media change
 * if the corresponding keep_data flag is non-zero. Positive values are
 * decremented after each probe.
 */
static int keep_data[4] = { 0,0,0,0 };

/*
 * Announce successful media type detection and media information loss after
 * disk changes.
 * Also used to enable/disable printing of overrun warnings.
 */
static ftd_msg[4] = { 0,0,0,0 };

/* Prevent "aliased" accesses. */

static fd_ref[4] = { 0,0,0,0 };
static fd_device[4] = { 0,0,0,0 };

/* Synchronization of FDC access. */
static volatile int format_status = FORMAT_NONE, fdc_busy = 0;
static struct wait_queue *fdc_wait = NULL, *format_done = NULL;

/* Errors during formatting are counted here. */
static int format_errors;

/* Format request descriptor. */
static struct format_descr format_req;

/*
 * Current device number. Taken either from the block header or from the
 * format request descriptor.
 */
#define CURRENT_DEVICE (format_status == FORMAT_BUSY ? format_req.device : \
   (CURRENT->dev))

/* Current error count. */
#define CURRENT_ERRORS (format_status == FORMAT_BUSY ? format_errors : \
    (CURRENT->errors))

/*
 * Threshold for reporting FDC errors to the console.
 * Setting this to zero may flood your screen when using
 * ultra cheap floppies ;-)
 */
static unsigned short min_report_error_cnt[4] = {2, 2, 2, 2};

/*
 * Rate is 0 for 500kb/s, 1 for 300kbps, 2 for 250kbps
 * Spec1 is 0xSH, where S is stepping rate (F=1ms, E=2ms, D=3ms etc),
 * H is head unload time (1=16ms, 2=32ms, etc)
 *
 * Spec2 is (HLD<<1 | ND), where HLD is head load time (1=2ms, 2=4 ms etc)
 * and ND is set means no DMA. Hardcoded to 6 (HLD=6ms, use DMA).
 */

/*
 * Track buffer and block buffer (in case track buffering doesn't work).
 * Because these are written to by the DMA controller, they must
 * not contain a 64k byte boundary crossing, or data will be
 * corrupted/lost. Alignment of these is enforced in boot/head.s.
 * Note that you must not change the sizes below without updating head.s.
 */
extern char tmp_floppy_area[BLOCK_SIZE];
extern char floppy_track_buffer[512*2*MAX_BUFFER_SECTORS];

static void redo_fd_request(void);

/*
 * These are global variables, as that's the easiest way to give
 * information to interrupts. They are the data used for the current
 * request.
 */
#define NO_TRACK 255

static int read_track = 0;	/* flag to indicate if we want to read entire track */
static int buffer_track = -1;
static int buffer_drive = -1;
static int cur_spec1 = -1;
static int cur_rate = -1;
static struct floppy_struct * floppy = floppy_type;
static unsigned char current_drive = 255;
static unsigned char sector = 0;
static unsigned char head = 0;
static unsigned char track = 0;
static unsigned char seek_track = 0;
static unsigned char current_track = NO_TRACK;
static unsigned char command = 0;
static unsigned char fdc_version = FDC_TYPE_STD;	/* FDC version code */

static void floppy_ready(void);

static void select_callback(unsigned long unused)
{
	floppy_ready();
}

static void floppy_select(unsigned int nr)
{
	static struct timer_list select = { NULL, NULL, 0, 0, select_callback };

	if (current_drive == (current_DOR & 3)) {
		floppy_ready();
		return;
	}
	seek = 1;
	current_track = NO_TRACK;
	current_DOR &= 0xFC;
	current_DOR |= current_drive;
	outb(current_DOR,FD_DOR);
	del_timer(&select);
	select.expires = 2;
	add_timer(&select);
}

static void motor_on_callback(unsigned long nr)
{
	running |= 0x10 << nr;
	floppy_select(nr);
}

static struct timer_list motor_on_timer[4] = {
	{ NULL, NULL, 0, 0, motor_on_callback },
	{ NULL, NULL, 0, 1, motor_on_callback },
	{ NULL, NULL, 0, 2, motor_on_callback },
	{ NULL, NULL, 0, 3, motor_on_callback }
};

static void motor_off_callback(unsigned long nr)
{
	unsigned char mask = ~(0x10 << nr);
	cli();
	running &= mask;
	current_DOR &= mask;
	outb(current_DOR,FD_DOR);
	sti();
}

static struct timer_list motor_off_timer[4] = {
	{ NULL, NULL, 0, 0, motor_off_callback },
	{ NULL, NULL, 0, 1, motor_off_callback },
	{ NULL, NULL, 0, 2, motor_off_callback },
	{ NULL, NULL, 0, 3, motor_off_callback }
};

static void floppy_on(unsigned int nr)
{
	unsigned char mask = 0x10 << nr;

	del_timer(motor_off_timer + nr);
	if (mask & running)
		floppy_select(nr);
	if (!(mask & current_DOR)) {
		del_timer(motor_on_timer + nr);
		motor_on_timer[nr].expires = HZ;
		add_timer(motor_on_timer + nr);
	}
	current_DOR &= 0xFC;
	current_DOR |= mask;
	current_DOR |= nr;
	outb(current_DOR,FD_DOR);
}

static void floppy_off(unsigned int nr)
{
	del_timer(motor_off_timer+nr);
	motor_off_timer[nr].expires = 3*HZ;
	add_timer(motor_off_timer+nr);
}

void request_done(int uptodate)
{
	timer_active &= ~(1 << FLOPPY_TIMER);
	if (format_status != FORMAT_BUSY)
		end_request(uptodate);
	else {
		format_status = uptodate ? FORMAT_OKAY : FORMAT_ERROR;
		wake_up(&format_done);
	}
}

/*
 * floppy-change is never called from an interrupt, so we can relax a bit
 * here, sleep etc. Note that floppy-on tries to set current_DOR to point
 * to the desired drive, but it will probably not survive the sleep if
 * several floppies are used at the same time: thus the loop.
 */
int floppy_change(struct buffer_head * bh)
{
	unsigned int mask = 1 << (bh->b_dev & 0x03);

	if (MAJOR(bh->b_dev) != MAJOR_NR) {
		printk("floppy_changed: not a floppy\n");
		return 0;
	}
	if (fake_change & mask) {
		buffer_track = -1;
		fake_change &= ~mask;
/* omitting the next line breaks formatting in a horrible way ... */
		changed_floppies &= ~mask;
		return 1;
	}
	if (changed_floppies & mask) {
		buffer_track = -1;
		changed_floppies &= ~mask;
		recalibrate = 1;
		return 1;
	}
	if (!bh)
		return 0;
	if (bh->b_dirt)
		ll_rw_block(WRITE, 1, &bh);
	else {
		buffer_track = -1;
		bh->b_uptodate = 0;
		ll_rw_block(READ, 1, &bh);
	}
	wait_on_buffer(bh);
	if (changed_floppies & mask) {
		changed_floppies &= ~mask;
		recalibrate = 1;
		return 1;
	}
	return 0;
}

#define copy_buffer(from,to) \
__asm__("cld ; rep ; movsl" \
	: \
	:"c" (BLOCK_SIZE/4),"S" ((long)(from)),"D" ((long)(to)) \
	:"cx","di","si")

static void setup_DMA(void)
{
	unsigned long addr,count;
	unsigned char dma_code;

	dma_code = DMA_WRITE;
	if (command == FD_READ)
		dma_code = DMA_READ;
	if (command == FD_FORMAT) {
		addr = (long) tmp_floppy_area;
		count = floppy->sect*4;
	} else {
		addr = (long) CURRENT->buffer;
		count = 1024;
	}
	if (read_track) {
/* mark buffer-track bad, in case all this fails.. */
		buffer_drive = buffer_track = -1;
		count = floppy->sect*floppy->head*512;
		addr = (long) floppy_track_buffer;
	} else if (addr >= LAST_DMA_ADDR) {
		addr = (long) tmp_floppy_area;
		if (command == FD_WRITE)
			copy_buffer(CURRENT->buffer,tmp_floppy_area);
	}
	cli();
	disable_dma(FLOPPY_DMA);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧洲中文字幕精品| 国产精品色噜噜| 亚洲午夜视频在线| 欧美系列在线观看| 一区二区三区在线免费视频| 91原创在线视频| 亚洲成人免费在线| 久久久国产精品麻豆| 9l国产精品久久久久麻豆| 精品少妇一区二区三区免费观看 | 亚洲国产精品ⅴa在线观看| 免费不卡在线视频| 日韩免费高清av| 国产精品77777竹菊影视小说| 日本一区二区高清| 色综合网色综合| 偷窥国产亚洲免费视频| 欧美一级在线视频| 成人黄页毛片网站| 樱桃视频在线观看一区| 欧美美女喷水视频| 国产一区二区在线免费观看| 国产精品久久久久一区二区三区共| 99久久精品费精品国产一区二区| 一区二区激情视频| 26uuu精品一区二区| 91日韩精品一区| 狠狠色综合日日| 亚洲成人资源在线| 综合分类小说区另类春色亚洲小说欧美| 午夜不卡av在线| 欧美国产乱子伦 | 日本视频一区二区| 久久精品人人爽人人爽| 91福利视频在线| 成人小视频在线| 美脚の诱脚舐め脚责91 | 亚洲视频在线观看一区| 久久精品视频一区| 日韩免费高清电影| 日韩欧美一级二级三级| 欧美高清一级片在线| 色成人在线视频| 色综合久久综合| 色婷婷激情久久| 在线亚洲欧美专区二区| 欧洲亚洲国产日韩| 欧美日韩一区 二区 三区 久久精品| av不卡一区二区三区| 成人免费不卡视频| 99久久综合狠狠综合久久| 一本大道久久a久久综合| 日本韩国欧美一区二区三区| 一本色道久久加勒比精品| 91浏览器在线视频| 91精品国产丝袜白色高跟鞋| 欧美男女性生活在线直播观看| 欧美三级韩国三级日本三斤 | 色欧美乱欧美15图片| 99麻豆久久久国产精品免费优播| 91麻豆文化传媒在线观看| 色噜噜狠狠色综合欧洲selulu| 欧美三级日韩三级国产三级| 日韩免费观看2025年上映的电影| 国产亚洲精品福利| 亚洲成人手机在线| 国产福利精品一区二区| 欧美体内she精高潮| 久久久青草青青国产亚洲免观| 中文字幕一区二区三区av| 日韩激情在线观看| 成人av资源在线观看| 欧美一区二区三区性视频| 国产精品毛片无遮挡高清| 日韩国产欧美三级| 91美女视频网站| 欧美不卡在线视频| 一区二区三区四区在线| 国产精品小仙女| 日韩视频不卡中文| 亚洲午夜私人影院| 国产成人啪免费观看软件| 欧美性生活大片视频| 成人免费一区二区三区在线观看| 日本不卡不码高清免费观看| 波多野结衣91| 亚洲成a人v欧美综合天堂| 成人午夜电影小说| 亚洲成人午夜影院| 国产成人综合视频| 91精品国产综合久久香蕉的特点| 久久久一区二区| 午夜激情一区二区三区| 色婷婷综合激情| 亚洲国产成人av网| 欧美伊人久久大香线蕉综合69| 亚洲欧美日韩久久精品| 成人黄动漫网站免费app| 中文字幕va一区二区三区| 成人综合在线网站| 国产精品日韩成人| 色综合色综合色综合色综合色综合| 亚洲欧美综合在线精品| 色综合久久中文综合久久97| 亚洲高清中文字幕| 日韩欧美不卡一区| 成人一区二区三区在线观看| 国产精品入口麻豆原神| 91成人在线精品| 精品在线观看免费| 中文字幕日韩一区| 欧美一区二区三区在线| 蜜臀精品久久久久久蜜臀 | 大胆亚洲人体视频| 亚洲在线观看免费视频| 欧美一区二区三区在线观看| 久久不见久久见中文字幕免费| 久久久午夜电影| 欧美三级欧美一级| 国产白丝网站精品污在线入口| 亚洲欧美一区二区三区国产精品| 欧美视频一二三区| 国产一区欧美一区| 午夜精品aaa| 亚洲精品视频一区| 亚洲精品一区二区精华| 91高清在线观看| 丁香网亚洲国际| 美女久久久精品| 午夜婷婷国产麻豆精品| 国产精品国产三级国产普通话三级| 成人综合婷婷国产精品久久 | 亚洲欧美日韩在线不卡| 欧美色中文字幕| 国产一区在线不卡| 免费日本视频一区| 一区二区三区欧美| 久久影院视频免费| 欧美视频一区二区| 欧美性xxxxx极品少妇| 国产一区二区三区久久久| 亚洲永久免费av| 亚洲午夜一区二区三区| 亚洲精品国产成人久久av盗摄| 亚洲另类在线一区| 亚洲成av人片一区二区| 午夜欧美电影在线观看| 午夜成人免费视频| 久久国产人妖系列| 国产一区二区不卡老阿姨| 麻豆国产欧美一区二区三区| 天天色天天操综合| 亚洲一区在线观看免费| 日韩av在线播放中文字幕| 日韩精品1区2区3区| 国产麻豆一精品一av一免费| 国产精品系列在线播放| 91在线精品秘密一区二区| 色婷婷国产精品| 日韩欧美久久久| 亚洲视频一区在线| 精品一区在线看| 99视频精品全部免费在线| 欧美午夜精品久久久久久超碰| 日韩一区二区三区视频在线观看 | 欧美电影免费观看高清完整版在线观看| 精品国产电影一区二区| 中文字幕亚洲电影| 亚洲国产综合视频在线观看| 国产一区二区三区久久久| 久久久99精品免费观看不卡| 日韩理论片网站| 国产成人综合亚洲91猫咪| 欧美日韩国产在线播放网站| 国产亚洲综合在线| 日本va欧美va精品发布| 成人免费视频视频在线观看免费| 欧美亚洲综合另类| 亚洲精品一二三四区| 国产一二精品视频| 欧美成人激情免费网| 婷婷激情综合网| 91福利精品第一导航| 亚洲国产激情av| 国产精品一区三区| 日韩精品一区二区在线观看| 一区二区三区色| 色婷婷狠狠综合| 一区二区三区在线视频观看58| 国产一区高清在线| 久久久久高清精品| 国产xxx精品视频大全| 久久精品视频免费观看| 成人激情文学综合网| 中文字幕中文在线不卡住| 99精品视频中文字幕| 亚洲欧美中日韩| 在线中文字幕不卡| 香港成人在线视频| 欧美一区二区三区视频免费播放|