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

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

?? floppy.c

?? linux0.11內核源代碼,學習內核入門必看
?? 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;#define immoutb_p(val,port) \__asm__("outb %0,%1\n\tjmp 1f\n1:\tjmp 1f\n1:"::"a" ((char) (val)),"i" (port))#define TYPE(x) ((x)>>2)#define DRIVE(x) ((x)&0x03)/* * Note that MAX_ERRORS=8 doesn't imply that we retry every bad read * max 8 times - some types of errors increase the errorcount by 2, * so we might actually retry only 5-6 times before giving up. */#define MAX_ERRORS 8/* * globals used by 'result()' */#define MAX_REPLIES 7static 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. Unlike minix * linux doesn't have a "search for right type"-type, as the code * for that is convoluted and weird. I've got enough problems with * this driver as it is. * * The 'stretch' tells if the tracks need to be boubled for some * types (ie 360kB diskette in 1.2MB drive etc). Others should * be self-explanatory. */static struct floppy_struct {	unsigned int size, sect, head, track, stretch;	unsigned char gap,rate,spec1;} floppy_type[] = {	{    0, 0,0, 0,0,0x00,0x00,0x00 },	/* no testing */	{  720, 9,2,40,0,0x2A,0x02,0xDF },	/* 360kB PC diskettes */	{ 2400,15,2,80,0,0x1B,0x00,0xDF },	/* 1.2 MB AT-diskettes */	{  720, 9,2,40,1,0x2A,0x02,0xDF },	/* 360kB in 720kB drive */	{ 1440, 9,2,80,0,0x2A,0x02,0xDF },	/* 3.5" 720kB diskette */	{  720, 9,2,40,1,0x23,0x01,0xDF },	/* 360kB in 1.2MB drive */	{ 1440, 9,2,80,0,0x23,0x01,0xDF },	/* 720kB in 1.2MB drive */	{ 2880,18,2,80,0,0x1B,0x00,0xCF },	/* 1.44MB diskette */};/* * Rate is 0 for 500kb/s, 2 for 300kbps, 1 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). */extern void floppy_interrupt(void);extern char tmp_floppy_area[1024];/* * These are global variables, as that's the easiest way to give * information to interrupts. They are the data used for the current * request. */static int cur_spec1 = -1;static int cur_rate = -1;static struct floppy_struct * floppy = floppy_type;static unsigned char current_drive = 0;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 = 255;static unsigned char command = 0;unsigned char selected = 0;struct task_struct * wait_on_floppy_select = NULL;void floppy_deselect(unsigned int nr){	if (nr != (current_DOR & 3))		printk("floppy_deselect: drive not selected\n\r");	selected = 0;	wake_up(&wait_on_floppy_select);}/* * 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(unsigned int nr){repeat:	floppy_on(nr);	while ((current_DOR & 3) != nr && selected)		interruptible_sleep_on(&wait_on_floppy_select);	if ((current_DOR & 3) != nr)		goto repeat;	if (inb(FD_DIR) & 0x80) {		floppy_off(nr);		return 1;	}	floppy_off(nr);	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){	long addr = (long) CURRENT->buffer;	cli();	if (addr >= 0x100000) {		addr = (long) tmp_floppy_area;		if (command == FD_WRITE)			copy_buffer(CURRENT->buffer,tmp_floppy_area);	}/* mask DMA 2 */	immoutb_p(4|2,10);/* output command byte. I don't know why, but everyone (minix, *//* sanches & canton) output this twice, first to 12 then to 11 */ 	__asm__("outb %%al,$12\n\tjmp 1f\n1:\tjmp 1f\n1:\t"	"outb %%al,$11\n\tjmp 1f\n1:\tjmp 1f\n1:"::	"a" ((char) ((command == FD_READ)?DMA_READ:DMA_WRITE)));/* 8 low bits of addr */	immoutb_p(addr,4);	addr >>= 8;/* bits 8-15 of addr */	immoutb_p(addr,4);	addr >>= 8;/* bits 16-19 of addr */	immoutb_p(addr,0x81);/* low 8 bits of count-1 (1024-1=0x3ff) */	immoutb_p(0xff,5);/* high 8 bits of count-1 */	immoutb_p(3,5);/* activate DMA 2 */	immoutb_p(0|2,10);	sti();}static void output_byte(char byte){	int counter;	unsigned char status;	if (reset)		return;	for(counter = 0 ; counter < 10000 ; counter++) {		status = inb_p(FD_STATUS) & (STATUS_READY | STATUS_DIR);		if (status == STATUS_READY) {			outb(byte,FD_DATA);			return;		}	}	reset = 1;	printk("Unable to send byte to FDC\n\r");}static int result(void){	int i = 0, counter, status;	if (reset)		return -1;	for (counter = 0 ; counter < 10000 ; counter++) {		status = inb_p(FD_STATUS)&(STATUS_DIR|STATUS_READY|STATUS_BUSY);		if (status == STATUS_READY)			return i;		if (status == (STATUS_DIR|STATUS_READY|STATUS_BUSY)) {			if (i >= MAX_REPLIES)				break;			reply_buffer[i++] = inb_p(FD_DATA);		}	}	reset = 1;	printk("Getstatus times out\n\r");	return -1;}static void bad_flp_intr(void){	CURRENT->errors++;	if (CURRENT->errors > MAX_ERRORS) {		floppy_deselect(current_drive);		end_request(0);	}	if (CURRENT->errors > MAX_ERRORS/2)		reset = 1;	else		recalibrate = 1;}	/* * Ok, this interrupt is called after a DMA read/write has succeeded, * so we check the results, and copy any buffers. */static void rw_interrupt(void){	if (result() != 7 || (ST0 & 0xf8) || (ST1 & 0xbf) || (ST2 & 0x73)) {		if (ST1 & 0x02) {			printk("Drive %d is write protected\n\r",current_drive);			floppy_deselect(current_drive);			end_request(0);		} else			bad_flp_intr();		do_fd_request();		return;	}	if (command == FD_READ && (unsigned long)(CURRENT->buffer) >= 0x100000)		copy_buffer(tmp_floppy_area,CURRENT->buffer);	floppy_deselect(current_drive);	end_request(1);	do_fd_request();}inline void setup_rw_floppy(void){	setup_DMA();	do_floppy = rw_interrupt;	output_byte(command);	output_byte(head<<2 | current_drive);	output_byte(track);	output_byte(head);	output_byte(sector);	output_byte(2);		/* sector size = 512 */	output_byte(floppy->sect);	output_byte(floppy->gap);	output_byte(0xFF);	/* sector size (0xff when n!=0 ?) */	if (reset)		do_fd_request();}/* * This is the routine called after every seek (or recalibrate) interrupt * from the floppy controller. Note that the "unexpected interrupt" routine * also does a recalibrate, but doesn't come here. */static void seek_interrupt(void){/* sense drive status */	output_byte(FD_SENSEI);	if (result() != 2 || (ST0 & 0xF8) != 0x20 || ST1 != seek_track) {		bad_flp_intr();		do_fd_request();		return;	}	current_track = ST1;	setup_rw_floppy();}/* * This routine is called when everything should be correctly set up * for the transfer (ie floppy motor is on and the correct floppy is * selected). */static void transfer(void){	if (cur_spec1 != floppy->spec1) {		cur_spec1 = floppy->spec1;		output_byte(FD_SPECIFY);		output_byte(cur_spec1);		/* hut etc */		output_byte(6);			/* Head load time =6ms, DMA */	}	if (cur_rate != floppy->rate)		outb_p(cur_rate = floppy->rate,FD_DCR);	if (reset) {		do_fd_request();		return;	}	if (!seek) {		setup_rw_floppy();		return;	}	do_floppy = seek_interrupt;	if (seek_track) {		output_byte(FD_SEEK);		output_byte(head<<2 | current_drive);		output_byte(seek_track);	} else {		output_byte(FD_RECALIBRATE);		output_byte(head<<2 | current_drive);	}	if (reset)		do_fd_request();}/* * Special case - used after a unexpected interrupt (or reset) */static void recal_interrupt(void){	output_byte(FD_SENSEI);	if (result()!=2 || (ST0 & 0xE0) == 0x60)		reset = 1;	else		recalibrate = 0;	do_fd_request();}void unexpected_floppy_interrupt(void){	output_byte(FD_SENSEI);	if (result()!=2 || (ST0 & 0xE0) == 0x60)		reset = 1;	else		recalibrate = 1;}static void recalibrate_floppy(void){	recalibrate = 0;	current_track = 0;	do_floppy = recal_interrupt;	output_byte(FD_RECALIBRATE);	output_byte(head<<2 | current_drive);	if (reset)		do_fd_request();}static void reset_interrupt(void){	output_byte(FD_SENSEI);	(void) result();	output_byte(FD_SPECIFY);	output_byte(cur_spec1);		/* hut etc */	output_byte(6);			/* Head load time =6ms, DMA */	do_fd_request();}/* * reset is done by pulling bit 2 of DOR low for a while. */static void reset_floppy(void){	int i;	reset = 0;	cur_spec1 = -1;	cur_rate = -1;	recalibrate = 1;	printk("Reset-floppy called\n\r");	cli();	do_floppy = reset_interrupt;	outb_p(current_DOR & ~0x04,FD_DOR);	for (i=0 ; i<100 ; i++)		__asm__("nop");	outb(current_DOR,FD_DOR);	sti();}static void floppy_on_interrupt(void){/* We cannot do a floppy-select, as that might sleep. We just force it */	selected = 1;	if (current_drive != (current_DOR & 3)) {		current_DOR &= 0xFC;		current_DOR |= current_drive;		outb(current_DOR,FD_DOR);		add_timer(2,&transfer);	} else		transfer();}void do_fd_request(void){	unsigned int block;	seek = 0;	if (reset) {		reset_floppy();		return;	}	if (recalibrate) {		recalibrate_floppy();		return;	}	INIT_REQUEST;	floppy = (MINOR(CURRENT->dev)>>2) + floppy_type;	if (current_drive != CURRENT_DEV)		seek = 1;	current_drive = CURRENT_DEV;	block = CURRENT->sector;	if (block+2 > floppy->size) {		end_request(0);		goto repeat;	}	sector = block % floppy->sect;	block /= floppy->sect;	head = block % floppy->head;	track = block / floppy->head;	seek_track = track << floppy->stretch;	if (seek_track != current_track)		seek = 1;	sector++;	if (CURRENT->cmd == READ)		command = FD_READ;	else if (CURRENT->cmd == WRITE)		command = FD_WRITE;	else		panic("do_fd_request: unknown command");	add_timer(ticks_to_floppy_on(current_drive),&floppy_on_interrupt);}void floppy_init(void){	blk_dev[MAJOR_NR].request_fn = DEVICE_REQUEST;	set_trap_gate(0x26,&floppy_interrupt);	outb(inb_p(0x21)&~0x40,0x21);}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91免费观看国产| 《视频一区视频二区| 欧美国产一区在线| 亚洲成年人影院| 99riav一区二区三区| 久久综合九色综合97婷婷| 亚洲在线成人精品| 成人午夜在线免费| 精品噜噜噜噜久久久久久久久试看| 中文欧美字幕免费| 国产精品中文欧美| 日韩一级欧美一级| 无码av免费一区二区三区试看| 成人免费视频网站在线观看| 久久这里只有精品视频网| 日韩电影免费在线观看网站| 日本道精品一区二区三区| 国产欧美精品一区二区色综合朱莉| 日本亚洲三级在线| 精品视频资源站| 一区二区三区在线不卡| av在线不卡观看免费观看| 国产精品天美传媒| 国产精品一线二线三线精华| 欧美成人一区二区| 久久精品噜噜噜成人88aⅴ| 欧美巨大另类极品videosbest| 一级女性全黄久久生活片免费| 99久久精品国产毛片| 国产精品乱人伦| 成人性生交大片| 亚洲欧洲韩国日本视频| 成人精品高清在线| 亚洲欧美日韩久久| 91极品美女在线| 亚洲一区在线观看免费观看电影高清 | 青青草成人在线观看| 欧美电影在线免费观看| 日韩精品成人一区二区三区| 欧美一区二区三区精品| 精品一区二区三区在线播放| 久久婷婷国产综合精品青草| 成人免费黄色在线| 亚洲美女精品一区| 91麻豆精品国产91| 国产在线一区观看| 国产精品国产精品国产专区不蜜| 91免费观看在线| 日韩福利电影在线| 久久久www成人免费无遮挡大片 | 国产区在线观看成人精品 | 亚洲美女电影在线| 6080午夜不卡| 国模少妇一区二区三区| 国产精品午夜免费| 欧美日韩国产三级| 精品一区二区在线视频| 中文字幕av不卡| 欧美性色黄大片| 蜜臀av性久久久久蜜臀aⅴ四虎 | 成人av影院在线| 亚洲国产欧美日韩另类综合| 日韩一区二区视频在线观看| 国产福利一区二区三区视频 | 麻豆精品在线播放| 日本一二三四高清不卡| 欧美视频一区二| 国产精品91一区二区| 亚洲午夜av在线| 久久女同互慰一区二区三区| 日本精品视频一区二区| 极品美女销魂一区二区三区| 伊人夜夜躁av伊人久久| 欧美成人福利视频| 在线精品亚洲一区二区不卡| 精品一区二区在线视频| 亚洲一区二区影院| 国产欧美日韩不卡免费| 欧美日韩高清在线| 99麻豆久久久国产精品免费| 久久精品国产在热久久| 亚洲影视在线观看| 国产精品人妖ts系列视频| 欧美一区二区三区在线电影| 91在线观看免费视频| 精品系列免费在线观看| 亚洲国产一二三| 亚洲欧美成人一区二区三区| 国产亚洲污的网站| 日韩精品最新网址| 欧美性大战久久久| 91黄色激情网站| 成人国产在线观看| 久久超级碰视频| 天天av天天翘天天综合网色鬼国产 | 日本aⅴ亚洲精品中文乱码| 亚洲欧美综合色| 久久久久久黄色| 日韩免费电影一区| 欧美一区二区视频在线观看| 欧美视频第二页| 欧美体内she精高潮| 91在线一区二区| 成人激情小说乱人伦| 国产91精品一区二区麻豆亚洲| 日本v片在线高清不卡在线观看| 一区二区三区四区蜜桃| 亚洲精品中文在线影院| 136国产福利精品导航| 中文字幕中文在线不卡住| 国产精品日日摸夜夜摸av| 国产亚洲精品精华液| 国产日韩精品视频一区| 国产亚洲精品精华液| 国产欧美日韩在线看| 国产欧美综合色| 国产精品久久免费看| 自拍偷拍国产亚洲| 亚洲精品v日韩精品| 亚洲综合一区二区三区| 亚洲一区二区av在线| 亚洲777理论| 青草国产精品久久久久久| 免费人成在线不卡| 九色porny丨国产精品| 国内外成人在线| 懂色av一区二区三区免费看| 成人国产精品免费网站| 99国产一区二区三精品乱码| 91美女在线看| 欧美日韩在线一区二区| 日韩一区二区三区免费看| 欧美成人精精品一区二区频| 国产日韩欧美精品一区| 日韩理论片网站| 午夜不卡av在线| 国产一区999| 一本久久a久久精品亚洲| 欧洲av在线精品| 日韩免费在线观看| 国产精品国产三级国产普通话三级 | 久久美女高清视频| 综合久久给合久久狠狠狠97色| 亚洲一二三区视频在线观看| 经典三级视频一区| 99热99精品| 日韩欧美国产一区二区在线播放| 久久精品人人做人人综合| 亚洲欧美一区二区在线观看| 婷婷综合另类小说色区| 国产成人精品一区二| 欧美午夜电影一区| 久久婷婷久久一区二区三区| 一区二区久久久| 激情六月婷婷久久| 欧美在线制服丝袜| 精品国产亚洲在线| 一区二区三区色| 久久福利视频一区二区| 91在线观看一区二区| 日韩一区二区在线免费观看| 中文字幕视频一区| 韩国v欧美v亚洲v日本v| 一本一道久久a久久精品综合蜜臀| 日韩欧美中文字幕精品| **欧美大码日韩| 韩国成人福利片在线播放| 国产成人自拍网| 91精品国产91热久久久做人人| 中文字幕一区二区三区视频| 日本欧美肥老太交大片| 在线观看亚洲一区| 欧美激情一区二区三区蜜桃视频| 日韩福利视频导航| 91高清在线观看| 国产欧美日韩另类一区| 久久99国内精品| 欧美一区二区三区影视| 亚洲福利视频导航| 日本精品视频一区二区| 中文字幕一区二区三区色视频| 极品少妇一区二区三区精品视频| 欧美人与禽zozo性伦| 亚洲伦在线观看| 99久久综合国产精品| 久久久久国产精品麻豆| 国模无码大尺度一区二区三区| 欧美一卡二卡在线观看| 日韩高清一区二区| 欧美日本在线观看| 亚洲成av人影院在线观看网| 色综合久久88色综合天天免费| 中文字幕欧美一区| 不卡av电影在线播放| 国产精品入口麻豆原神| 成人综合在线观看| 亚洲欧洲成人自拍| 91热门视频在线观看| 亚洲美女淫视频| 欧美在线观看视频在线|