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

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

?? sys.c

?? 這是DOS操作系統啟動的源代碼 里面是匯編語言 包括了部分的驅動程序
?? C
字號:

/****************************************************************/
/*								*/
/*			      sys.c				*/
/*			      DOS-C				*/
/*								*/
/*		       sys utility for DOS-C			*/
/*								*/
/*			Copyright (c) 1991			*/
/*			Pasquale J. Villani			*/
/*			All Rights Reserved			*/
/*								*/
/* This file is part of DOS-C.					*/
/*								*/
/* DOS-C is free software; you can redistribute it and/or	*/
/* modify it under the terms of the GNU General Public License	*/
/* as published by the Free Software Foundation; either version	*/
/* 2, or (at your option) any later version.			*/
/*								*/
/* DOS-C is distributed in the hope that it will be useful, but	*/
/* WITHOUT ANY WARRANTY; without even the implied warranty of	*/
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See	*/
/* the GNU General Public License for more details.		*/
/*								*/
/* You should have received a copy of the GNU General Public	*/
/* License along with DOS-C; see the file COPYING.  If not,	*/
/* write to the Free Software Foundation, 675 Mass Ave,		*/
/* Cambridge, MA 02139, USA.					*/
/****************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <io.h>
#include <dos.h>
#include <ctype.h>
#include <mem.h>
#include "../../hdr/portab.h"
#include "../../hdr/device.h"

BYTE *pgm = "sys";

BOOL fl_reset(VOID);
COUNT fl_rd_status(WORD);
COUNT fl_read(WORD, WORD, WORD, WORD, WORD, BYTE FAR *);
COUNT fl_write(WORD, WORD, WORD, WORD, WORD, BYTE FAR *);
BOOL fl_verify(WORD, WORD, WORD, WORD, WORD, BYTE FAR *);
BOOL fl_format(WORD, BYTE FAR *);
VOID get_boot(COUNT);
VOID put_boot(COUNT);
BOOL check_space(COUNT, BYTE *);
COUNT ltop(WORD *, WORD *, WORD *, COUNT, COUNT, LONG, byteptr);
BOOL copy(COUNT, BYTE *);
BOOL DiskReset(COUNT);
COUNT DiskRead(WORD, WORD, WORD, WORD, WORD, BYTE FAR *);
COUNT DiskWrite(WORD, WORD, WORD, WORD, WORD, BYTE FAR *);

/*								*/
/* special word packing prototypes				*/
/*								*/
#ifdef NATIVE
# define getlong(vp, lp) (*(LONG *)(lp)=*(LONG *)(vp))
# define getword(vp, wp) (*(WORD *)(wp)=*(WORD *)(vp))
# define getbyte(vp, bp) (*(BYTE *)(bp)=*(BYTE *)(vp))
# define fgetlong(vp, lp) (*(LONG FAR *)(lp)=*(LONG FAR *)(vp))
# define fgetword(vp, wp) (*(WORD FAR *)(wp)=*(WORD FAR *)(vp))
# define fgetbyte(vp, bp) (*(BYTE FAR *)(bp)=*(BYTE FAR *)(vp))
# define fputlong(lp, vp) (*(LONG FAR *)(vp)=*(LONG FAR *)(lp))
# define fputword(wp, vp) (*(WORD FAR *)(vp)=*(WORD FAR *)(wp))
# define fputbyte(bp, vp) (*(BYTE FAR *)(vp)=*(BYTE FAR *)(bp))
#else
VOID getword(VOID *, WORD *);
VOID getbyte(VOID *, BYTE *);
VOID fgetlong(VOID FAR *, LONG FAR *);
VOID fgetword(VOID FAR *, WORD FAR *);
VOID fgetbyte(VOID FAR *, BYTE FAR *);
VOID fputlong(LONG FAR *, VOID FAR *);
VOID fputword(WORD FAR *, VOID FAR *);
VOID fputbyte(BYTE FAR *, VOID FAR *);
#endif

#define	SEC_SIZE	512
#define NDEV		4
#define COPY_SIZE	16384
#define	NRETRY		5

static struct media_info
{
	ULONG	mi_size;		/* physical sector size		*/
	UWORD	mi_heads;		/* number of heads (sides)	*/
	UWORD	mi_cyls;		/* number of cyl/drive		*/
	UWORD	mi_sectors;		/* number of sectors/cyl	*/
	ULONG	mi_offset;		/* relative partition offset	*/
};

union
{
	BYTE	bytes[2 * SEC_SIZE];
	boot	boot_sector;
} buffer;

static struct media_info miarray[NDEV] =
{
	{720l, 2, 40, 9, 0l},
	{720l, 2, 40, 9, 0l},
	{720l, 2, 40, 9, 0l},
	{720l, 2, 40, 9, 0l}
};

#define PARTOFF	0x1be
#define N_PART 4

static struct
{
	BYTE	peBootable;
	BYTE	peBeginHead;
	BYTE	peBeginSector;
	UWORD	peBeginCylinder;
	BYTE	peFileSystem;
	BYTE	peEndHead;
	BYTE	peEndSector;
	UWORD	peEndCylinder;
	LONG	peStartSector;
	LONG	peSectors;
} partition[N_PART];

static int DrvMap[4] = {0, 1, 0x80, 0x81};

COUNT drive, active;
UBYTE newboot[SEC_SIZE], oldboot[SEC_SIZE];

#define SBSIZE		51
#define SBOFFSET	11

#define SIZEOF_PARTENT	16

#define FAT12		0x01
#define	FAT16SMALL	0x04
#define	EXTENDED	0x05
#define	FAT16LARGE	0x06

#define N_RETRY		5

COUNT 
get_part (COUNT drive, COUNT idx)
{
	REG retry = N_RETRY;
	REG BYTE *p = (BYTE *)&buffer.bytes[PARTOFF + (idx * SIZEOF_PARTENT)];
	REG ret;
	BYTE packed_byte, pb1;

	do
	{
		ret = fl_read((WORD)DrvMap[drive], (WORD)0, (WORD)0, (WORD)1, (WORD)1, (byteptr)&buffer);
	} while (ret != 0 && --retry > 0);
	if(ret != 0)
		return FALSE;
	getbyte((VOID *)p, &partition[idx].peBootable);
	++p;
	getbyte((VOID *)p, &partition[idx].peBeginHead);
	++p;
	getbyte((VOID *)p, &packed_byte);
	partition[idx].peBeginSector = packed_byte & 0x3f;
	++p;
	getbyte((VOID *)p, &pb1);
	++p;
	partition[idx].peBeginCylinder = pb1 + ((0xc0 & packed_byte) << 2);
	getbyte((VOID *)p, &partition[idx].peFileSystem);
	++p;
	getbyte((VOID *)p, &partition[idx].peEndHead);
	++p;
	getbyte((VOID *)p, &packed_byte);
	partition[idx].peEndSector = packed_byte & 0x3f;
	++p;
	getbyte((VOID *)p, &pb1);
	++p;
	partition[idx].peEndCylinder = pb1 + ((0xc0 & packed_byte) << 2);
	getlong((VOID *)p, &partition[idx].peStartSector);
	p += sizeof(LONG);
	getlong((VOID *)p, &partition[idx].peSectors);
	return TRUE;
}


VOID main(argc, argv)
COUNT argc;
BYTE *argv[];
{
	if(argc != 2)
	{
		fprintf(stderr, "Useage: %s drive\n drive = A,B,etc.\n", pgm);
		exit(1);
	}

	drive = *argv[1] - (islower(*argv[1]) ? 'a' : 'A');
	if(drive < 0 || drive >= NDEV)
	{
		fprintf(stderr, "%s: drive out of range\n", pgm);
		exit(1);
	}

	if(!DiskReset(drive))
	{
		fprintf(stderr, "%s: cannot reset drive %c:",
			drive, 'A' + drive);
		exit(1);
	}

	get_boot(drive);

	if(!check_space(drive, oldboot))
	{
		fprintf(stderr, "%s: cannot transfer system files\n", pgm);
		exit(1);
	}

	put_boot(drive);

	if(!copy(drive, "ipl.sys"))
	{
		fprintf(stderr, "%s: cannot copy \"IPL.SYS\"\n", pgm);
		exit(1);
	}
	if(!copy(drive, "kernel.exe"))
	{
		fprintf(stderr, "%s: cannot copy \"KERNEL.EXE\"\n", pgm);
		exit(1);
	}
	if(!copy(drive, "boot.bin"))
	{
		fprintf(stderr, "%s: cannot copy \"BOOT.BIN\"\n", pgm);
		exit(1);
	}
	if(!copy(drive, "command.com"))
	{
		fprintf(stderr, "%s: cannot copy \"COMMAND.COM\"\n", pgm);
		exit(1);
	}
	exit(0);
}


VOID put_boot(drive)
COUNT drive;
{
	COUNT i;
	COUNT ifd;
	WORD head, track, sector, ret;
	WORD count;

	if(drive >= 2)
	{
		head = partition[active].peBeginHead;
		sector = partition[active].peBeginSector;
		track = partition[active].peBeginCylinder;
	}
	else
	{
		head = 0;
		sector = 1;
		track = 0;
	}

	if((ifd = open("boot.bin", O_RDONLY | O_BINARY)) < 0)
	{
		fprintf(stderr, "%s: can't open\"boot.bin\"\n", pgm);
		exit(1);
	}

	if(read(ifd, newboot, SEC_SIZE) < SEC_SIZE)
	{
		fprintf(stderr, "%s: error read \"boot.bin\"", pgm);
		exit(1);
	}

	close(ifd);

	if((i = DiskRead(DrvMap[drive], head, track, sector, 1, (BYTE far *)oldboot)) != 0)
	{
		fprintf(stderr, "%s: disk read error (code = 0x%02x)\n", pgm, i & 0xff);
		exit(1);
	}

	memcpy(&newboot[SBOFFSET], &oldboot[SBOFFSET], SBSIZE);

	if((i = DiskWrite(DrvMap[drive], head, track, sector, 1, (BYTE far *)newboot)) != 0)
	{
		fprintf(stderr, "%s: disk write error (code = 0x%02x)\n", pgm, i & 0xff);
		exit(1);
	}
}


VOID get_boot(drive)
COUNT drive;
{
	COUNT i;
	COUNT ifd;
	WORD head, track, sector, ret;
	WORD count;

	if(drive >= 2)
	{
		head = partition[active].peBeginHead;
		sector = partition[active].peBeginSector;
		track = partition[active].peBeginCylinder;
	}
	else
	{
		head = 0;
		sector = 1;
		track = 0;
	}

	if((i = DiskRead(DrvMap[drive], head, track, sector, 1, (BYTE far *)oldboot)) != 0)
	{
		fprintf(stderr, "%s: disk read error (code = 0x%02x)\n", pgm, i & 0xff);
		exit(1);
	}
}


BOOL check_space(drive, BlkBuffer)
COUNT drive;
BYTE *BlkBuffer;
{
	BYTE *bpbp;
	BYTE nfat;
	UWORD nfsect;
	ULONG hidden, count;
	ULONG block;
	UBYTE nreserved;
	UCOUNT i;
	WORD track, head, sector;
	UBYTE buffer[SEC_SIZE];
	ULONG bpb_huge;
	UWORD bpb_nsize;

	/* get local information				*/
	getbyte((VOID *)&BlkBuffer[BT_BPB + BPB_NFAT], &nfat);
	getword((VOID *)&BlkBuffer[BT_BPB + BPB_NFSECT], &nfsect);
	getlong((VOID *)&BlkBuffer[BT_BPB + BPB_HIDDEN], &hidden);
	getbyte((VOID *)&BlkBuffer[BT_BPB + BPB_NRESERVED], &nreserved);

	getlong((VOID *)&BlkBuffer[BT_BPB + BPB_HUGE], &bpb_huge);
	getword((VOID *)&BlkBuffer[BT_BPB + BPB_NSIZE], &bpb_nsize);

	count = miarray[drive].mi_size = bpb_nsize == 0 ?
	 bpb_huge : bpb_nsize;

	/* Fix media information for disk			*/
	getword((&(((BYTE *)&BlkBuffer[BT_BPB])[BPB_NHEADS])), &miarray[drive].mi_heads);
	head = miarray[drive].mi_heads;
	getword((&(((BYTE *)&BlkBuffer[BT_BPB])[BPB_NSECS])), &miarray[drive].mi_sectors);
	if(miarray[drive].mi_size == 0)
		getlong(&((((BYTE *)&BlkBuffer[BT_BPB])[BPB_HUGE])), &miarray[drive].mi_size);
	sector = miarray[drive].mi_sectors;
	if(head == 0 || sector == 0)
	{
		fprintf(stderr, "Drive initialization failure\n");
		exit(1);
	}
	miarray[drive].mi_cyls = count / (head * sector);

	return;
}

/*									*/
/* Do logical block number to physical head/track/sector mapping	*/
/*									*/
static COUNT ltop(trackp, sectorp, headp, unit, count, strt_sect, strt_addr)
WORD *trackp, *sectorp, *headp;
REG COUNT unit;
LONG strt_sect;
COUNT count;
byteptr strt_addr;
{
#ifdef I86
	ULONG ltemp;
#endif
	REG ls, ps;

#ifdef I86
	/* Adjust for segmented architecture				*/
	ltemp = (((ULONG)mk_segment(strt_addr) << 4) + mk_offset(strt_addr)) & 0xffff;
	/* Test for 64K boundary crossing and return count large	*/
	/* enough not to exceed the threshold.				*/
	count = (((ltemp + SEC_SIZE * count) & 0xffff0000l) != 0l)
		? (0xffffl - ltemp) / SEC_SIZE
		: count;
#endif

	*trackp = strt_sect / (miarray[unit].mi_heads * miarray[unit].mi_sectors);
	*sectorp = strt_sect % miarray[unit].mi_sectors + 1;
	*headp = (strt_sect % (miarray[unit].mi_sectors * miarray[unit].mi_heads))
		/ miarray[unit].mi_sectors;
	if(((ls = *headp * miarray[unit].mi_sectors + *sectorp - 1) + count) >
		(ps = miarray[unit].mi_heads * miarray[unit].mi_sectors))
		count = ps - ls;
	return count;
}


BOOL copy(drive, file)
COUNT drive;
BYTE *file;
{
	BYTE dest[64];
	COUNT ifd, ofd, ret;
	BYTE buffer[COPY_SIZE];
	struct ftime ftime;

	sprintf(dest, "%c:\\%s", 'A'+drive, file);
	if((ifd = open((BYTE FAR *)file, O_RDONLY | O_BINARY)) < 0)
	{
		fprintf(stderr, "%s: \"%s\" not found\n", pgm, file);
		return FALSE;
	}
	_fmode = O_BINARY;
	if((ofd = creat((BYTE FAR *)dest, S_IREAD | S_IWRITE)) < 0)
	{
		fprintf(stderr, "%s: can't create\"%s\"\n", pgm, dest);
		return FALSE;
	}
	while((ret = read(ifd, (VOID *)buffer, COPY_SIZE)) == COPY_SIZE)
		write(ofd, (VOID *)buffer, ret);
	if(ret >= 0)
		write(ofd, (VOID *)buffer, ret);
	getftime(ifd, &ftime);
	setftime(ofd, &ftime);
	close(ifd);
	close(ofd);
	return TRUE;
}


BOOL DiskReset(COUNT Drive)
{
	REG COUNT idx;

	/* Reset the drives						*/
	fl_reset();

	if(Drive >= 2 && Drive < NDEV)
	{
		COUNT RetCode;

		/* Retrieve all the partition information		*/
		for(RetCode = TRUE, idx = 0; RetCode && (idx < N_PART); idx++)
			RetCode = get_part(Drive, idx);
		if(!RetCode)
			return FALSE;

		/* Search for the first DOS partition and start		*/
		/* building the map for the hard drive			*/
		for(idx = 0; idx < N_PART; idx++)
		{
			if(partition[idx].peFileSystem == FAT12
			|| partition[idx].peFileSystem == FAT16SMALL
			|| partition[idx].peFileSystem == FAT16LARGE)
			{
				miarray[Drive].mi_offset
				 = partition[idx].peStartSector;
				active = idx;
				break;
			}
		}
	}

	return TRUE;
}

COUNT DiskRead(WORD drive, WORD head, WORD track, WORD sector, WORD count, BYTE FAR *buffer)
{
	int nRetriesLeft;

	for(nRetriesLeft = NRETRY; nRetriesLeft > 0; --nRetriesLeft)
	{
		if(fl_read(drive, head, track, sector, count, buffer) == count)
			return count;
	}
	return 0;
}

COUNT DiskWrite(WORD drive, WORD head, WORD track, WORD sector, WORD count, BYTE FAR *buffer)
{
	int nRetriesLeft;

	for(nRetriesLeft = NRETRY; nRetriesLeft > 0; --nRetriesLeft)
	{
		if(fl_write(drive, head, track, sector, count, buffer) == count)
			return count;
	}
	return 0;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91国偷自产一区二区开放时间| 天天色图综合网| 成年人午夜久久久| 中文字幕视频一区二区三区久| 99国产精品久久久久久久久久久| 18成人在线视频| 欧美亚洲禁片免费| 男男视频亚洲欧美| 久久亚洲一级片| www.亚洲精品| 亚洲国产精品久久久久秋霞影院 | 成人一区二区三区视频| 国产精品国产精品国产专区不片| 色综合咪咪久久| 日韩av电影天堂| 国产日韩欧美电影| 精品视频999| 国产成人鲁色资源国产91色综| 午夜电影一区二区| 精品剧情v国产在线观看在线| 国产.精品.日韩.另类.中文.在线.播放| 国产精品―色哟哟| 91精品久久久久久久99蜜桃| 精品中文av资源站在线观看| 国产精品日韩成人| 欧美美女网站色| 成人国产电影网| 日韩极品在线观看| 国产精品美女一区二区在线观看| 欧美日韩久久一区二区| 春色校园综合激情亚洲| 午夜激情综合网| 中文字幕一区日韩精品欧美| 欧美一区二区在线不卡| 成人综合激情网| 秋霞午夜鲁丝一区二区老狼| 国产精品国产精品国产专区不片| 欧美一区二区三区小说| 色婷婷精品久久二区二区蜜臀av | 国产欧美久久久精品影院| 欧美日韩精品一区二区天天拍小说| 国产成人午夜视频| 奇米精品一区二区三区四区| 一区二区三区不卡视频| 欧美韩国日本综合| 日韩一区二区三区免费看| 色一情一乱一乱一91av| 国产成人无遮挡在线视频| 日韩二区在线观看| 亚洲丰满少妇videoshd| 国产精品国产自产拍在线| 精品国产免费一区二区三区香蕉| 欧美日韩视频在线观看一区二区三区| 丁香天五香天堂综合| 麻豆一区二区三区| 日韩激情在线观看| 同产精品九九九| 亚洲精品乱码久久久久久久久| 国产三级一区二区三区| 日韩一区二区影院| 91精品欧美一区二区三区综合在| 欧美吻胸吃奶大尺度电影| 99精品桃花视频在线观看| 国产91精品免费| 高清shemale亚洲人妖| 国产在线视频不卡二| 毛片一区二区三区| 免费亚洲电影在线| 蜜桃av一区二区在线观看| 男人的天堂久久精品| 午夜亚洲国产au精品一区二区| 一区二区三区中文在线| 亚洲美女在线国产| 自拍偷拍亚洲综合| 日本伊人色综合网| 青青草原综合久久大伊人精品| 日韩精品国产精品| 秋霞av亚洲一区二区三| 久久精品免费看| 久久精品免费观看| 国产成人在线观看免费网站| 国产iv一区二区三区| 成人综合激情网| 91视频com| 欧美日韩综合一区| 欧美一区二区三区的| 亚洲精品一区二区三区四区高清| 337p粉嫩大胆色噜噜噜噜亚洲| 久久综合久久鬼色| 国产精品每日更新在线播放网址| 国产精品情趣视频| 亚洲精品一二三| 亚洲成人一区在线| 毛片av一区二区| 成人美女视频在线观看| 在线观看欧美黄色| 69精品人人人人| 亚洲精品在线一区二区| 亚洲国产精品v| 亚洲国产精品久久久久婷婷884 | 国产精品美女久久久久av爽李琼| 亚洲日本电影在线| 午夜精品免费在线观看| 精品一区二区综合| 不卡一区二区中文字幕| 欧美久久久久免费| 久久久精品综合| 亚洲综合免费观看高清在线观看| 日韩成人精品在线观看| 丁香一区二区三区| 欧美日韩国产经典色站一区二区三区| 欧美tickling网站挠脚心| 国产精品高清亚洲| 欧美bbbbb| 色综合天天性综合| 日韩欧美国产不卡| 亚洲三级免费观看| 国内外成人在线视频| 91高清在线观看| 久久精品视频免费| 首页欧美精品中文字幕| 成人午夜av在线| 日韩欧美一级在线播放| 亚洲乱码国产乱码精品精小说| 久久成人免费电影| 一本到高清视频免费精品| 欧美zozo另类异族| 亚洲成人精品在线观看| 岛国av在线一区| 欧美videossexotv100| 一区二区三区欧美久久| 成人综合婷婷国产精品久久| 7777精品伊人久久久大香线蕉| 最新国产成人在线观看| 国产乱码精品一区二区三区忘忧草 | 男女性色大片免费观看一区二区 | 国产不卡在线一区| 日韩精品一区在线观看| 亚洲电影一区二区三区| 99re这里只有精品视频首页| 26uuu精品一区二区| 天堂成人免费av电影一区| 91麻豆免费观看| 国产精品色呦呦| 国产福利一区二区三区在线视频| 91麻豆精品国产综合久久久久久 | 国产欧美一区二区三区在线老狼| 午夜精品在线看| 在线免费不卡视频| 亚洲天堂av老司机| 国产精品一级在线| 久久久久久久久久久久久女国产乱| 午夜欧美视频在线观看| 欧美亚洲国产一卡| 亚洲精品乱码久久久久久黑人| av在线播放成人| 国产丝袜在线精品| 高清av一区二区| 国产亚洲欧美激情| 丁香一区二区三区| 中文字幕二三区不卡| 成人h动漫精品| 国产精品久久久久毛片软件| 成人免费高清视频| 中文字幕一区免费在线观看| 成人18视频在线播放| 亚洲欧洲性图库| 色系网站成人免费| 亚洲国产你懂的| 欧美精品免费视频| 免费成人在线播放| 久久综合色综合88| 懂色av中文字幕一区二区三区| 久久久五月婷婷| 成人av电影免费观看| 亚洲黄色小视频| 欧美精品色综合| 久久精品噜噜噜成人88aⅴ| 久久久久免费观看| 成人免费视频免费观看| 亚洲视频一区二区免费在线观看| 日本电影亚洲天堂一区| 性做久久久久久久久| 日韩免费看的电影| 国产99精品国产| 亚洲国产精品欧美一二99| 欧美一级久久久久久久大片| 国产酒店精品激情| 亚洲日本va在线观看| 欧美精品久久天天躁| 激情偷乱视频一区二区三区| 国产精品久久久久一区二区三区共 | 91高清视频在线| 久久精品国内一区二区三区| 久久久夜色精品亚洲| 日本高清免费不卡视频| 精品一区二区三区在线观看国产| 国产调教视频一区| 欧美午夜电影一区| 国产福利91精品一区二区三区|