示例#1
0
//---------------------------------------------------------------------------------------------------------------------
//
//  从MS FAT12表中查找某一簇的下一簇(有待研究)
//
//---------------------------------------------------------------------------------------------------------------------
unsigned short Msdos_12Next(const unsigned short cluster)
{
	unsigned short blk, next, offset;
	unsigned char  buf[512];

	if(cluster > Fat12_Info.fat_entries)
		NTLDR_DBG("Next is a Bad Cluster!");

	blk = ((cluster*3)/2) / 512;
	offset = ((cluster*3)/2) % 512;


	floppy_read(Fat12_Info.fat_base+blk, 1, buf);

	next=*(unsigned short *)(buf+offset);


	if((offset & 511) == 511){
		floppy_read(Fat12_Info.fat_base+blk+1,1,buf);
		next=next+buf[0]*256;
	}


	if (cluster & 1) 
		next = next >> 4;   //1230 >> 0123
	else
示例#2
0
文件: floppy.c 项目: n3on/madOS
void floppy_calibrate()
{
	floppy_out(FC_RECALIBRATE);
	floppy_out(0x0); //driver
		
	floppy_waitIrq();
		
	floppy_out(FC_SENSE_INTERRUPT);
	floppy_read(FP_STATUS_REGISTER_A);
	floppy_read(FP_STATUS_REGISTER_A);
	
}
示例#3
0
void command_line_parser(const char* command) {
    if(streq(command, "clear")) {
        tty_init(&task_admin->tasks[0]);
    } else if(streq(command, "free")) {
        printf("\nMem Free:%uM\n", free_mem() / 1024 / 1024);
    } else if(streq(command, "ls")) {
        printf("\n\tName\tType\tDate\t\tSize\n");
        struct DirectoryEntry* en = floppy_read(ROOT_DIRECTORY, 14);

        while(1) {
            if(en->name[0] == 0)
                break;

            char name[9], type[4];
            uint32_t mon = en->wtime >> 8;
            uint32_t day = en->wtime & 0xff;
            memcpy(name, en->name, 8);
            memcpy(type, en->name + 8, 3);
            name[8] = '\0';
            type[3] = '\0';
            printf("%s\t%s\t%u-%u-%u\t%u\n", name, type, en->wdate, mon, day, en->fsize);
            en++;
        }

        printf("\n");
    } else if(streqn(command, "./", 2) && strlen(command + 2) > 0) {
示例#4
0
文件: floppyC.c 项目: TonyLianLong/os
uint8_t floppy_read_address(uint32_t address) {
    address /= 0x200;
    uint8_t cylinder = address/36;
    uint8_t head = (address/18)%2;
    uint8_t sector = address%18+1;
    return floppy_read(cylinder,head,sector);
}
示例#5
0
文件: fd.c 项目: huangrui/Thunix
/* debug fd read */
void Debug(void)
{
	char buf[512];

	LOG("BUF addr: %p\n", buf);

        floppy_read(838, buf);
	hexdump(buf, 128);
}
示例#6
0
文件: floppy.c 项目: n3on/madOS
void floppy_reset()
{
	outb(FP_DIGITAL_OUTPUT_REGISTER,0x00);
	outb(FP_DIGITAL_OUTPUT_REGISTER,0x0C);	
	floppy_waitIrq();
	floppy_out(FC_SENSE_INTERRUPT);
	floppy_read(FP_STATUS_REGISTER_A);
	floppy_read(FP_STATUS_REGISTER_A); 
	
	//geschwindigkeit auf 500 kb/s setzen
	outb(FP_CONFIGURATION_CONTROL_REGISTER, 0x00);
	
	floppy_out(FC_SPECIFY);
	floppy_out(0xdf);
	floppy_out(0x02);
	
	floppy_calibrate();
	
	kprint("\nFloppy zurueckgesetzt\n");
}
示例#7
0
文件: floppy.c 项目: n3on/madOS
void floppy_set(int head, int cylinder)
{
	int i;
	
	while(i<10)
	{
		floppy_out(FC_SEEK);
		floppy_out(head<<2);
		floppy_out(cylinder);
		
		floppy_waitIrq();
		
		floppy_out(FC_SENSE_INTERRUPT);
		floppy_read(FP_STATUS_REGISTER_A);
		floppy_read(FP_STATUS_REGISTER_A);

 		
	}
	
}
示例#8
0
文件: fd.c 项目: huangrui/Thunix
/*
 * The two following function handles multi-sectors reading
 * and writing.
 */
int floppy_reads(int sector, void *buf, unsigned int sectors)
{
	int res = 0;

	while (sectors--) {
		res = floppy_read(sector++, buf);
		if (res < 0)
			break;
		buf += 512;
	}

	return res;
}
示例#9
0
int main()
{
    unsigned k = 0;
    BYTE     buffer[512];
    unsigned long long start_time;

    fd32_event_init();
    if (fdc_setup(drive_detected) < 0) return -1;
    atexit(dispose);

    printf("Going to write some data in all sectors...\n");
    getchar();
    start_time = uclock();
    do
    {
        memset(buffer, k, sizeof(buffer));
        int res = floppy_write(&drive0, k, 1, buffer);
        if (res == FDC_NODISK) break;
        else if (res < 0) printf("Error on block %u\n", k);
        if (k % (drive0.fdd->fmt->sec_per_trk * drive0.fdd->fmt->heads) == 0)
            printf("%llu: block %u written\n", uclock() * 1000 / UCLOCKS_PER_SEC, k);
    }
    while (++k < drive0.fdd->fmt->size);
    printf("Write test elapsed in %llu ms\n", (uclock() - start_time) * 1000 / UCLOCKS_PER_SEC);
    puts("Going to read data from all sectors...\n");
    getchar();
    k = 0;
    start_time = uclock();
    do
    {
        BYTE check[512];
        memset(check, k, sizeof(check));
        int res = floppy_read(&drive0, k, 1, buffer);
        if (res == FDC_NODISK) break;
        else if (res < 0) printf("Error on block %u\n", k);
        if (k % (drive0.fdd->fmt->sec_per_trk * drive0.fdd->fmt->heads) == 0)
            printf("%llu: block %u read\n", uclock() * 1000 / UCLOCKS_PER_SEC, k);
        if (memcmp(buffer, check, sizeof(buffer)))
            printf("Block %u MISMATCH!\n", k);
    }
    while (++k < drive0.fdd->fmt->size);
    printf("Read test elapsed in %llu ms\n", (uclock() - start_time) * 1000 / UCLOCKS_PER_SEC);
    printf("All tests completed.\n");
    return 0;
}
示例#10
0
文件: wd1793.c 项目: BigEd/speccy2010
static byte wd_floppy_read()
{
	wd.dsr = floppy_read();
	wd.crc = crc_add(wd.crc, wd.dsr);
	return wd.dsr;
}