Well at first I thought that my FDC driver is not working, But now I have figured out the problem. It's with the FAT12 BPB struct.
Following is the code:
fat.h
Code: Select all
#include "kore\kmsgs.h"
#include "iostream.h"
#include "drivers\fdc\fdc.h"
#include "kore\kalloc.h"
#if !defined ( __FAT_H_ )
#define __FAT_H_
struct fat_bpb
{
unsigned char jmp[3];
unsigned char oem_name[8];
unsigned int bytes_per_sector;
unsigned char sectors_per_cluster;
unsigned int num_reserved_sectors;
unsigned char num_fats;
unsigned int num_root_directories;
unsigned int total_sectors;
unsigned char media_desc;
unsigned int num_sectors_per_fat_16;
unsigned int sectors_per_track;
unsigned int num_heads;
unsigned long num_hidden_sectors;
unsigned long num_sectors_32;
unsigned char logical_drive_num;
unsigned char reserved;
unsigned char extended_signature;
unsigned long serial_num;
unsigned char volume_lable[12];
unsigned char fs_type[8];
unsigned char boot_code[448];
unsigned int magic_num;
}__attribute__ ((packed));
extern const char * FAT_ID;
class FAT
{
private:
fat_bpb fat12_boot_info;
public:
FAT();
~FAT();
int init();
};
extern FAT fat;
#endif
fat.cpp
Code: Select all
#include "drivers\FAT\FAT.h"
#if !defined ( __FAT_CPP_ )
#define __FAT_CPP_
const char * FAT_ID = "FAT";
FAT::FAT()
{
;
}
FAT::~FAT()
{
;
}
int FAT::init()
{
cout<<endl;
cout<<"FAT: ";
cout<<"\n\tNot Implemented";
unsigned char * ch = (unsigned char *) &fat12_boot_info;
fdc.read_block(0, (unsigned char *) &fat12_boot_info);
printf("\n0x%x\n", &fat12_boot_info);
printf("0x%x\n", ch);
printf("%d\n", sizeof(fat12_boot_info));
printf("%s\n", fat12_boot_info.volume_lable);
unsigned char che[512];
unsigned char * chp = (unsigned char *) &che;
fdc.read_block(0, chp);
int ctr = 4;
while(ctr !=9)
{
printf("%c", che[ctr]);
ctr++;
}
//fdc.read_block(0, (unsigned char *)&fat12_boot_info);
/*printf("%s", fat12_boot_info.oem_name);
printf("\n%d", fat12_boot_info.sec_size);
printf("\n%s", fat12_boot_info.volume_label);*/
return KMSG_FALIURE;
}
FAT fat;
#endif
can anyone help?