⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 init.c

📁 PDA上的包含NANDFlash和FAT文件系统的源码
💻 C
字号:
/*************************************************************
File Name: init.c					     *
**************************************************************
Programmer: Huang Giun-Haur
Last Modified Date: 1999/2/1
Compiler : Gnu Cross-compiler
Platform : X86 protection mode
Usage : functions needed to read MSDOS's boot sector

	void	hd_software_reset()	// optional
	short	FAT_get_hd_chs()	// optional
	short	read_partition_sector(unsigned short *sectorBuffer)
	short	read_boot_sector(unsigned short *sectorBuffer)

*************************************************************/

#include <sys/syscall.h>

// test
//#include <stdio.h>
// test
#ifdef __WIN32__
#include "../include/ata_emu.h"
#endif

#include "../../FileSys/include/FileSys.h"


#include "../include/fat1x.h"
#include "../include/cluster.h"
#include "../include/init.h"

#ifdef FAT_USE_PCMCIA
  /**** added by chilong ****/
  //#include "../pcm/cf_typedef.h"
  /**** added by chilong ****/

  #include "../include/ata_pcc.h"
  //#include "pcmcia/include/pcmcia.h"
#ifndef __WIN32__
  #include "pcmcia/include/pcmcia.h"
#endif


#elif defined FAT_USE_MMC //thhuang
  #include "../../../../../driver/mmc/include/mmc_drv.h"
  #include "../include/ata_pcc.h"
#else
  #include "../include/ata_pcc.h"
  #include "../../nflash/include/nflash.h"
#endif

#ifdef FAT1X_DEBUG
	#include "../include/fdebug.h"
#endif



#ifdef FAT_ID



/* The following are used in read_boot_sector */
/*
unsigned short		FATSecPerCluster;	// no. of sectors per cluster
unsigned short		FATSecPerFAT;	// no. of sectors per FAT
unsigned short		FATNumFAT;		// no. of number of FATs
unsigned long		FATBytesPerCluster;	// no. of bytes per cluster
unsigned long		FATWordsPerCluster;	// no. words per cluster
unsigned long		FATBootBegin;	// the starting sector of BOOT
unsigned long		FAT1Begin;	// the starting sector of FAT1
unsigned long		FAT2Begin;	// the starting sector of FAT2
unsigned long		FATRootBegin;	// the starting sector of ROOT dir
unsigned long		FATDataBegin;	// the starting sector of data cluster
unsigned short		FATTotalCluster;	// total no. of clusters
unsigned short		FATSecPerROOT;	// no. of sectors per ROOT
*/
/* The following are used in read_boot_sector */
unsigned short		FATSecPerCluster[DRIVE_NUM];
unsigned short		FATSecPerFAT[DRIVE_NUM];
unsigned short		FATNumFAT[DRIVE_NUM];
unsigned long		FATBytesPerCluster[DRIVE_NUM];
unsigned long		FATWordsPerCluster[DRIVE_NUM];
unsigned long		FATBootBegin[DRIVE_NUM];
unsigned long		FAT1Begin[DRIVE_NUM];
unsigned long	  	FAT2Begin[DRIVE_NUM];
unsigned long	  	FATRootBegin[DRIVE_NUM];
unsigned long	  	FATDataBegin[DRIVE_NUM];
unsigned long	  	FATTotalSector[DRIVE_NUM];
unsigned short  	FATTotalCluster[DRIVE_NUM];
unsigned short  	FATSecPerROOT[DRIVE_NUM];
unsigned char		FATType[DRIVE_NUM];
/* searching for a free cluster starts here */
unsigned short		FATFreeClusterBegin[DRIVE_NUM];
unsigned char		FATDriveOn[DRIVE_NUM];

char			FATAvailDrive = 0;

/* marked by chilong 02/08/2002
int 			FATDirSemaphoreID;
int	 		FATFatSemaphoreID;
int 			FATFtableSemaphoreID;
*/

/**** modified by chilong 02/08/2002 ****/
int 			FATDirSemaphoreID = -1;
int	 		FATFatSemaphoreID = -1;
int 			FATFtableSemaphoreID = -1;
/**** modified by chilong 02/08/2002 ****/

int			InitFAT	= FALSE;
int			FATIsLBA	= FALSE;
int			FATErrno;

struct FAT_C_H_S FATDiskInfo;


// fat1x.c
extern int FATHdDriver;
extern struct FAT_FILE **FATHandleTable;

// cluster.c
extern int FATAtaSemaphoreID;

// FileSys.c
//extern short *FileSysHandleTable[MAX_OPEN_FILE];
extern short **FileSysHandleTable;



/*************************************************************
Function : FAT_init
Description : 
	Read Partition Sector and Boot Sector to get the
	information needed for later use
Inputs :
	Addressing type
		0 - CHS
		1 - LBA
Outputs :
	ERROR_OUTOFMEMORY
        ERROR_READPARTITION
        ERROR_READBOOTSECTOR
        ERROR_CREATESEMAPHORE
Notes:
	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -