freelanceprogrammers.org Forum Index » C

Plz help me(Urgent, Problem 2 )


View user's profile Post To page top
ar_frenz Posted: Tue Jul 29, 2003 6:03 pm


Joined: 05 Jul 2003

Posts: 8
Plz help me(Urgent, Problem 2 )
Compiler : Turbo C++ 3.0Hello Friends,
             I have written a program to read hard drive`s master boot record and then read the partition table extract the partition information ;
after bit masking i get the  starting CHS value and ending CHS value can anybody tell me how do i find the capacity or sizze of a partition when i have starting and ending  CHS value ;
you can assume the max CHS values is  cc,hh,ss;
i`m attaching my code plz do have a look ;
CHS  : Cylinder,Head,Sector                  
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
Reply with quote
Send private message
View user's profile Post To page top
shantanu_k06 Posted: Tue Jul 29, 2003 10:53 pm


Joined: 19 Jul 2003

Posts: 29
Plz help me(Urgent, Problem 2 )
Hi Arumita,

Your post contained no attached code. Nevertheless...

Discovering partition-size should be only a simple
calculation if you already know the starting and
ending CC/HH/SS values, needing you to only further
know the sectors-per-track and total-sectors values
beforehand.

If
ending values = E_CC, E_HH, E_SS
beginning values = B_CC, B_HH, B_SS
sectors per track = N_SPT
total heads = N_H
bytes per sector = N_BPS (512 in usual cases)

Then,
capacity of a cylinder (N_SPC) = N_H * N_SPT * N_BPS
capacity of partition = (see below)
(E_CC - B_CC) * N_SPC +
(E_HH - B_HH) * N_SPT * N_BPS +
(E_SS - B_SS) * N_BPS


If you don`t want to calculate (for a formatted
partition only) even that, read the boot record of
that partition which has that info already there
(probably, I don`t exactly remember). Info on boot
sector was published in a magazine (Computers &
Communications, year 1994, month I don`t remember,
maybe May).

Regards,
Shantanu

--- Arumita De <ar_frenz@...> wrote:
> Compiler : Turbo C++ 3.0
> Hello Friends,
> I have written a program to read hard
> drive`s master boot record and then read the
> partition table extract the partition information ;
> after bit masking i get the starting CHS value and
> ending CHS value
> can anybody tell me how do i find the capacity or
> sizze of a partition
> when i have starting and ending CHS value ;
> you can assume the max CHS values is cc,hh,ss;
> i`m attaching my code plz do have a look ;
>
> CHS : Cylinder,Head,Sector


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
Reply with quote
Send private message
View user's profile Post To page top
joe_steeve_1981 Posted: Wed Jul 30, 2003 9:13 am


Joined: 26 Jul 2003

Posts: 20
Plz help me(Urgent, Problem 2 )
On Tue, 29 Jul 2003 06:03:01 -0700 (PDT), Arumita De
<ar_frenz@...> wrote:

There was no attached code.

> after bit masking i get the starting CHS value and ending CHS value
> can anybody tell me how do i find the capacity or sizze of a partition
> when i have starting and ending CHS value ;

Hmm.. Using CHS, you wont be able to address more than 8GB of disk
space. All most every bootloader today disregards the information in
these fields. In order to find the size of the partition, you`ve to read
the last four bytes of the partition entry in the partition table. It
contains the partition length in LBA. I`ve herewith inlined a struct
which I used in one of my old projects. You are welcome to use it.
It is the structure of one entry in the partition table. You can have
four such entries in the table. the `partlen` entry contains the number
of sectors in a partition. the `psectorno` entry contains the starting
of the partition. the `pbooti` entry is the `boot flag`. the `pos_i`
entry is the `file system type indicator`

I hope this helps.

Cheers,
Joe

--
"Software is like sex; Its better when it is free"
-- Linus Torvalds

"The kingdom of heaven is spread out upon the earth,
and men do not see it" --Jesus, Gospel of Thomas 113

Visit:http://www.joesteeve.tk/
PS:> I hate HTML mail

--

Partition entry structure >

typedef struct _partition
{
unsigned char pbooti;
unsigned char pbeg_head;
unsigned char pbeg_sect;
unsigned char pbeg_cyl;
unsigned char pos_i;
unsigned char pend_head;
unsigned char pend_sect;
unsigned char pend_cyl;
unsigned long psectorno;
unsigned long ppartlen;

} partition __attribute__ ((packed));
Reply with quote
Send private message
View user's profile Post To page top
ar_frenz Posted: Wed Jul 30, 2003 3:14 pm


Joined: 05 Jul 2003

Posts: 8
Plz help me(Urgent, Problem 2 )
Thank you friends ,
we impleneted ur suggestion for floppy disk
we intialized it using int 13 & service 0 still its not working .
for intializig we intialized the disk using `dir a:` and in explorer
A:
but still it`s not working plz suggest me what to do .

Thanking you in anticipation.

our code is attached here :


plz see the previous thread 130,131,146,150 at
http://groups.yahoo.com/group/Programmers-Town/messages




-----------------------------------------
#include<iostream.h>
#include<dos.h>
#include<math.h>
#include<stdlib.h>
#include<graphics.h>
#include<bios.h>
#include<stdio.h>
#include<conio.h>

class Sector
{
int c,h,s;
Sector *next;
public :
Sector(int c, int h, int s ); //this has to be use
display();
correct();
};
class Disk
{
unsigned long int signature;
unsigned char buffer[512];
long int c,h,s;
short int drive;
int status;


public :

Disk(int);
void init();
scantext();
void norton();
unsigned char verifyDisk( unsigned char drive,unsigned char
sectorsToRead,
unsigned char head, unsigned char track,
unsigned sector,unsigned char far *bufferPtr);

};


class scr
{
strlen1(char *);
void highlight(char **menu,int n, int h,int x,int y,int
max,int bk,int color,int color1);
void scr::ebox(int x1,int y1,int x2,int y2,int color);
int scr::binary(int bk,int color);
void scr::checkkey();
public:
char menu();
int initgraphics();
int clear();
int closegraphics();
int flash();
int cls();
int inittextmode();
int color(int);
int menu(char **s,int n,int x,int y,int bk,int color,int
color1);
};


int scan,ascii;

int main()
{
char *menuitem[]={"Text Mode","Graphics Mode","About","Exit"};
Disk o(0x0);
scr screen;
screen.initgraphics();
screen.flash();
screen.closegraphics();
screen.inittextmode();
screen.cls();
while(1)
{
screen.cls();
char ch = screen.menu(menuitem,4,25,8,1,15,9);
switch(ch)
{
case 1 : screen.inittextmode();
screen.cls();
o.scantext();
screen.cls();
break;
case 2 : screen.initgraphics();
o.norton();
screen.closegraphics();
break;

case 3 : screen.initgraphics();
screen.flash();
screen.closegraphics();
break;
case 4 : exit(0);

}
}
getch();
return(0);
}

Disk::Disk(int d)
{
drive = d;
c=100;
h=2;
s=14;
status=0;
if (d==0 || d==1||d ==2 )
{
union REGS i,o; /*Inittialize floppy Disk*/
i.x.ax=0;
int86(0x13,&i,&o);
}

int result = verifyDisk(d,1,0,0,1,buffer);
if(result)
{
printf("Error in reading Boot Record ");
getch();
exit(1);
}
}

/*verify sectors from diskette.Returns 0 or an interrupt 13h error
code.*/

unsigned char Disk::verifyDisk( unsigned char drive,unsigned char
sectorsToRead,
unsigned char head, unsigned char track,
unsigned sector,unsigned char far *bufferPtr)

{

union REGS regs;
struct SREGS sregs;

regs.h.ah=4; /*ah= Verify sectors*/
regs.h.al=sectorsToRead; /*al=no of sectors to read*/
regs.x.bx=FP_OFF(bufferPtr); /*Buffer offset*/
regs.h.dh=head; /*dh=head*/
regs.h.dl=drive; /*dl=drive no*/
regs.h.ch=track; /* ch=track no*/
regs.h.cl=sector; /*cl=sector no*/
sregs.es =FP_SEG(bufferPtr); /*es=Buffer segment*/
int86x(0x13,&regs,&regs,&sregs); /*call bios*/
return(regs.h.ah);/*ah=0 or error code*/
}

Disk::scantext()
{
int result;
float total=c*h*s+h*s+s,current=0;

cout<<"scanning the disk ";
for(int i=0;i<h;i++)
for(int j=0;j<c;j++)
for(int k=0;k<s;k++)
{
result=verifyDisk(drive,1,h, c, s,buffer);
current=j*h*s+i*s+k;
gotoxy(24,5);
printf("%3.2f %%",current/total*100);
if(result==0x04)
{
cout<<"
Sector not found";
status=1;
}
else if(result==0x0A)
{
cout<<"
Bad sector detected";
status=1;
}
else if(result==0x0B)
{
cout<<"
Bad track detected";
status=1;
}
} //for
gotoxy(24,5);
printf("%3.2f %%",current/total*100);

if(status==0)
cout<<"
no errorrs detected";
else
cout<<"
errors detected ";
getch();
return status;
}

void Disk::init()
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;

/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "c:\turboc3");

/* read result of initialization */
errorcode = graphresult();

if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s
", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}


}

void Disk::norton()
{
int x1=80,y1=50,x2=553,y2=410;
int outer_color=7;
int inner_color=9;
int result;
int x=x1+39,y=y1+39,color=2;
int good=2,bad=4;
int badsector=0,count=0;
char str[60];
settextstyle(10,0,2);
outtextxy(150,0,"Norton Disk Doctor 5.0");
setfillstyle(1,inner_color);
floodfill(152,22,getmaxcolor());
floodfill(179,22,getmaxcolor());
floodfill(193,22,getmaxcolor());
floodfill(208,22,getmaxcolor());
floodfill(223,22,getmaxcolor());
floodfill(243,22,getmaxcolor());
floodfill(270,22,getmaxcolor());
floodfill(290,22,getmaxcolor());
floodfill(290,15,getmaxcolor());
floodfill(305,22,getmaxcolor());
floodfill(318,22,getmaxcolor());
floodfill(352,22,getmaxcolor());
floodfill(378,22,getmaxcolor());
floodfill(395,22,getmaxcolor());
floodfill(415,22,getmaxcolor());
floodfill(415,22,getmaxcolor());
floodfill(430,22,getmaxcolor());
floodfill(442,22,getmaxcolor());
floodfill(430,22,getmaxcolor());
floodfill(475,25,getmaxcolor());
floodfill(510,17,getmaxcolor());
floodfill(492,37,getmaxcolor());
setfillstyle(1,outer_color);
rectangle(x1,y1,x2,y2);
floodfill(x1+1,y1+1,getmaxcolor());
rectangle(x1+39,y1+39,x2-38,y2-39);
setfillstyle(1,inner_color);
floodfill(121,121,getmaxcolor());
setcolor(0);
rectangle(x1+38,y1+38,x2-37,y2-38);
setcolor(15);

/* Capture Screen */
//rectangle(x1,y2+15,x2,y2+35);
int size = imagesize(x1,y2+15,x2,y2+35);
//rectangle(x1+200,y2+40,x2,y2+60);
int size2= imagesize(x1+200,y2+40,x2,y2+60);
void far *vdu = malloc(size),*vdu2=malloc(size2);
if(vdu==NULL || vdu2==NULL)
{
printf("Memmory is not available ");
getch();
exit(1);
}
getimage(x1,y2+15,x2,y2+35,vdu);
getimage(x1+200,y2+40,x2,y2+60,vdu2);
settextstyle(2,0,6);
for(int i=0;i<h;i++)
for(int j=0;j<c;j++)
for(int k=0;k<s;k++)
{
result=verifyDisk(drive,1,h, c, s,buffer);
switch(result)
{
case 0x04 : color=bad;
sprintf(str,"Sector Not Found ");
break;
case 0x0A : color=bad;
sprintf (str,"BED SECTOR DETECTED ");
break;
case 0x0B :
color=bad;
sprintf(str,"Bed Track Deteted ");
break;
case 0xAA : color=bad;
sprintf(str,"Drive is not ready");
break;
default : color=good;
}

//displaying sector
rectangle(x,y,x+6,y+6);
setfillstyle(1,color);
floodfill(x+1,y+1,getmaxcolor());

/* Displaying Last Eror */
outtextxy(x1+55,y2+40," Last Error : ");
putimage(x1+200,y2+40,vdu2,0);
outtextxy(x1+205,y2+40,str);

/* Displaying Bad Sector No */
sprintf(str,"Total : %ld Current : %ld Bad Sector : %
d",c*h*s,count,0,badsector);
putimage(x1,y2+15,vdu,0);
setcolor(inner_color);
outtextxy(x1+5,y2+15,str);
setcolor(15);

// Incrementing x,y,count
x+=6;
count++;
if(x>=x2-42)
{
x=x1+39;
y+=6;
}
if(y>=y2-40) // If inner rectangle is full draw it
once again
{
getch();
y=y1+39;
setcolor(0);
for(int l=x1+39;l<x2-38;l++)
rectangle(x1+39,y1+39,l,y1+39);
for(l=y1+40;l<y2-40;l++)
rectangle(x1+39,y1+39,x2-38,l);
setcolor(15);
rectangle(x1+39,y1+39,x2-38,y2-39);
setfillstyle(1,inner_color);
floodfill(121,121,getmaxcolor());
setcolor(0);
rectangle(x1+38,y1+38,x2-37,y2-38);
setcolor(15);
}
} //for
}

int scr::menu(char **s,int n,int x,int y,int bk,int color,int color1)
{
int i=6,max=0,flage=1;
for(i=0;i<n;i++)
if(max<strlen1((char*)s[i]))
max=strlen1(s[i]);
_setcursortype(_NOCURSOR);
ebox(x,y,x+4+max,y+1+n,9);
highlight(s,n,0,x+2,y+1,max,bk,color,color1);
i=0;
while(flage)
{
checkkey();
if(scan==72)
if(i==0)
i=n-1;
else
i--;
if(scan==80)
if(i==n-1)
i=0;
else
i++;

highlight(s,n,i,x+2,y+1,max,bk,color,color1);
if(ascii==13 && scan==28)
flage=0;
}
_setcursortype(_NORMALCURSOR);
return(i+1);

}
int scr::initgraphics()
{
int gdriver = DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode, "c:\turboc3");
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s
", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* return with error code */
}
for (int x= 80,col=1;x<=600;x+=200,col++)
{
setfillstyle(1,col);
rectangle(x,460,x+10,470);
floodfill(x+1,461,getmaxcolor());
if (col==2) col++;
}
settextstyle(2,0,4);
outtextxy(115,460,"Allocated Area");
outtextxy(315,460,"Empty Memory Block");
outtextxy(515,460,"Process");
return(1);
}
int scr::clear()
{
cleardevice();
return 0;
}
int scr::closegraphics()
{
closegraph();
return 0;
}
int scr::flash(void)
{
int x,y;
struct time a;
gettime(&a);
if (a.ti_hour>=19)
setbkcolor(8);
else if (a.ti_hour >=12 && a.ti_hour < 19)
setbkcolor(9);
else if (a.ti_hour >= 7 && a.ti_hour < 12)
setbkcolor(5);
else
setbkcolor(2);

cleardevice();
setlinestyle(1,1,9);
for(x=680,y=-250;y<110;x-=1,y+=1)
{
rectangle(5,5,getmaxx()-5,getmaxy()-5);
rectangle(10,10,getmaxx()-10,getmaxy()-10);
settextstyle(6,0,3);
outtextxy(230,100,"Actual Implementation of ");
settextstyle(10,0,4);
outtextxy(x,140,"Doctor");
outtextxy(y,140," Disk");
cleardevice();
rectangle(5,5,getmaxx()-5,getmaxy()-5);
rectangle(10,10,getmaxx()-10,getmaxy()-10);
outtextxy(x,140,"Doctor");
outtextxy(y,140," Disk");
}

settextstyle(6,0,3);
outtextxy(230,100,"Actual Implementation of ");
settextstyle(6,0,2);
outtextxy(400,370,"Developed By :");
settextstyle(5,0,2);
outtextxy(480,400,"Arumita De");
getch();
return 0;
}
int scr::cls()
{
clrscr();
return 0;
}
int scr::inittextmode()
{
textmode(3);
return 0;
}
int scr::color(int i)
{
textcolor(i);
textbackground(0);
return 0;
}

void scr::checkkey()
{
union REGS i,o;
while(!kbhit);
i.h.ah=0;
int86(22,&i,&o);
scan=o.h.ah;
ascii=o.h.al;
}

void scr::highlight(char **menu,int n, int h,int x,int y,int max,int
bk,int color,int color1)
{
int counter=0,attr=0,i,k;
highvideo();
while(counter<n)
{
gotoxy(x-1,y++);
if(h!=counter)
{
attr=color1;
}
else
{
attr=binary(bk,color);
}
textattr(attr);
cprintf(" ");
cprintf(menu[counter]);
k=strlen1(menu[counter]);
for(i=k;i<=max;i++)
cprintf(" ");
counter++;
}
textcolor(15);

}
int scr::binary(int bk,int color)
{
int i=8;
i|= bk;
i<<=4;
i|=color;
return(i);
}

void scr::ebox(int x1,int y1,int x2,int y2,int color)
{
int i;
textcolor(color);
gotoxy(x1,y1);
cprintf("%c",201);
for(i=x1+1;i<x2;i++)
cprintf("%c",205);
cprintf("%c",187);
for(i=y1+1;i<y2;i++)
{
gotoxy(x2,i);
cprintf("%c",186);
}
gotoxy(x2,y2);
cprintf("%c",188);
for(i=x2-1;i>x1;i--)
{
gotoxy(i,y2);
cprintf("%c",205);
}
gotoxy(i,y2);
cprintf("%c",200);
for(i=y2-1;i>y1;i--)
{
gotoxy(x1,i);
cprintf("%c",186);
}
}

int scr::strlen1(char *str)
{
int i;
for( i=0; *str ;str++,i++);
return(i);
}
Reply with quote
Send private message
View user's profile Post To page top
shantanu_k06 Posted: Wed Jul 30, 2003 7:33 pm


Joined: 19 Jul 2003

Posts: 29
Plz help me(Urgent, Problem 2 )
If you happen to read this mail early, please try the solution once again in FULL-MSDOS mode. This may have something to do with INT-13H revectoring by MS-Windows and DPMI (Dos Protected Mode Interface). I am at workplace now -- I`ll look further into it when I reach my residence and then maybe I`ll be in a position to tell better.
 
I perfectly understand that you have an urgent requirement to solve the issue.
 
Regards,
Shantanuar_frenz <ar_frenz@...> wrote:
 
---snipped---
 
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
Reply with quote
Send private message
View user's profile Post To page top
shantanu_k06 Posted: Wed Jul 30, 2003 9:51 pm


Joined: 19 Jul 2003

Posts: 29
Plz help me(Urgent, Problem 2 )
I tried taking a look at your program. It doesn`t
compile. Lots of compile-errors in Turbo C++ 3.0 when
I tried.

BTW, I missed a vital point there yesterday. Only
initializing the FDC isn`t sufficient. You also have
to set the media/disk type for the floppy first, prior
to accessing it. (Despite whatever amount of crap the
documentation says, that it should be called only
prior to formatting a floppy.) The technique which I
am describing below, is tested again a while ago in
Windows 98 Second Edition compiled with Turbo C++ 3.0
compiler in COMPACT model.

The suggestion remains the same, albeit the details
slightly changed.

1. Prior to every fresh floppy-access, call init()
2. After every floppy I/O error, call init() or
reset() [depends on your case]
3. DON`T DO IT FOR HARD DISKS

Pseudo-code for init() is given below:

// prepare floppy for access
int init()
{
int err = 0; // error code returned by INT13H

// step 1 -- reset FDC (i.e. call func 00H)
reset();

// step 2 -- try setting media type with func 18H
// This should work for most cases, but not all
// (There`s a less-known issue on this about BIOS
// manufacturers disagreeing on single interface
// (about IBM PC PS/2 compatibility)
err = set_media_type(); // should call func 18H

// (did it fail saying "bad command" ?)
if (err == BAD_COMMAND && // (error code 01H)
(media_type == FLOPPY_1440 || media_type ==
FLOPPY_2880))
{
// step 3 -- try setting disk type with func 17H
// If this step doesn`t work too, there`s something
// wrong with your FDC, or your BIOS, or your OS
err = set_disk_type_(); // should call func 17H
}

// step 4 -- reset FDC again
reset();

// step 5 -- return the error code
return err;
}


***** Details on func 18H (set media type for format)
*****

Entry:
AH = 18H
CH = lower 8 bits of number of tracks
CL = high 2 bits of number of tracks (6, 7), and
sectors per track (bits 0-5)
DL = drive number (0-7)

Returns:
CF (Carry flag) --> clear if no errors (you may ignore
this and see AH)
AH = 00h (if requested combination supported)
01h (if function not available)
0Ch (if not supported or drive type unknown)
80h (if there`s no media in drive)
ES:DI = pointer to 11-byte disk parameter table for
media type

Note:
1. Floppy disk must be present in the drive
2. The documentation says this func should be called
prior to formatting a disk with INT 13H Fn 05H so the
BIOS can set the correct data rate for the media. But
I found this to be required even for
simple-read/writes.
3. If the change line is active for the specified
drive, it is reset.


***** Details on func 17H (set disk type for format)
*****

Entry:
AH = 17H
AL = 00h (not used)
01h (160, 180, 320, or 360KB diskette in 360kb
drive)
02h (360 KB diskette in 1.2 MB drive)
03h (1.2 MB diskette in 1.2 MB drive)
04h (720 KB disklette in 720 KB drive)
DL = drive number (0-7)

Returns:
CF (Carry Flag) --> set on error (you may ignore this,
and see AH)
AH = status of operation (same as output of func 01H)

Note:
1. This function is probably enhanced for the PS/2
series to detect 1.44 in 1.44 and 720 KB in 1.4 MB.
2. This function is not supported for floppy disks on
the PC or XT.
3. If the change line is active for the specified
drive, it is reset.
4. The BIOS sets the data rate for the specified drive
and media type. The rate is 250k/sec for
double-density media and 500k/sec for high density
media. The proper hardware is required.


Goodluck!!

Regards,
Shantanu


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
Reply with quote
Send private message
View user's profile Post To page top
arifali_007 Posted: Thu Jul 31, 2003 2:39 pm


Joined: 07 Jul 2003

Posts: 14
Plz help me(Urgent, Problem 2 )
> Hmm.. Using CHS, you wont be able to address more than 8GB of disk
> space.


how do i access more than 8 GB using int 13h and service no
42 i know that but i don`t know how to interpret the resultant values
tell if you know .

> In order to find the size of the partition, you`ve to read
> the last four bytes of the partition entry in the partition table.
>It > contains the partition length in LBA.

i tried that also but it wasn`t working correctly . :-( don`t know
why

>I`ve herewith inlined a struct
> which I used in one of my old projects. You are welcome to use it.

thank you very much :-) joe i also have written a class whci contain
all the attributes of partition . and you don`t have to any
calculation for finding these attributes just pass the 16 bytes
(which describe the partition) to constructor of thuis partition
class it will automatically do that for you .

here is my class defination and constructor defination any one can
use it can suggest me if it can be improved .

class Partition
{
public :
unsigned char hex[16];
unsigned short int active;
unsigned short int type;
unsigned int starting_head,ending_head;
unsigned int starting_sector,ending_sector;
unsigned long int starting_cylinder,ending_cylinder;
unsigned long int first_logical_sector,length;
unsigned long int size;
static char *FileSystem[256];
Partition(unsigned char arr[16]);
};


Partition::Partition(unsigned char arr[16])
{
/*Actie Bit */
active=arr[0];
/*Type of Partition*/
type=arr[4];

/*Interpreting the bits for Head*/
starting_head=arr[1];
ending_head=arr[5];

/*Interpreting the bits for Cylinder usig bit Masking */
unsigned int temp1,temp2 = arr[3]>>6;
temp1 = temp2<<8;
temp1|= arr[2];
starting_cylinder = temp1;

temp2 = arr[7]>>6;
temp1 = temp2<<8;
temp1|= arr[6];
ending_cylinder= temp1;

/*Interpreting the bits for Sector usig bit Masking */
unsigned char temp3;
temp3 =arr[3];
temp3 <<=2;
temp3 >>=2;
starting_sector=temp3;

temp3 =arr[7];
temp3 <<=2;
temp3 >>=2;
ending_sector=temp3;


length = *(unsigned long int*)arr[0xC];
first_logical_sector = *(unsigned long int*)arr[0x8];
size = (unsigned long int )((float)length*512/1024/1024/1024);
for(int i =0;i<16;i++)
hex[i]=arr[i];
}



-Arif
Reply with quote
Send private message
View user's profile Post To page top
joe_steeve_1981 Posted: Thu Jul 31, 2003 8:06 pm


Joined: 26 Jul 2003

Posts: 20
Plz help me(Urgent, Problem 2 )
On Thu, 31 Jul 2003 09:39:07 -0000, "arifali_007"
<arifali_007@...> wrote:

> how do i access more than 8 GB using int 13h and service no
> 42 i know that but i don`t know how to interpret the resultant values
> tell if you know .

Refer Ralf Brown`s Interrupt list. I dont have it now to tell you how
things work exactly. But I have a piece of C code., again from my
project which is worth a look

-------------------------------
Use this code with Turbo C

/*
* The parameter packet--
* Contains the the parameters such as address,
* no of sectors and such for 0x42 and 0x43 function
* calls.
*/
typedef struct _dskaddrpkt
{
unsigned char size;
unsigned char reserved;
unsigned int noofsectors;
unsigned int buffoffset;
unsigned int buffseg;
unsigned long sectorno;
unsigned long useless;

} dskaddrpkt;

dskaddrpkt dap;

......

/*Size of the parameter packet 0x10 = 16 Bytes*/
dap.size = 0x10;

/* I forgot why i put 0x00 here., but it dosent
* hinder anywhere. */
dap.useless = 0x00;

/* No. of sectors you want to read or write
I think there is a upper limit on this. I dont
know how much. You can refer Ralf Brown for that.*/
dap.noofsectors = nsecs;

/* The starting sector number */
dap.sectorno=sectorno; /* LBA */

/* The buffer to/from where the sectors should be
read/written respectively */
dap.buffoffset=(unsigned int)buff;
dap.buffseg= _DS;

/* Finally call BIOS to do the job */
i.h.ah = 0x42; /* 0x42 to read and 0x43 to write */
i.h.al = 0x00; /* Again no idea why i put 0x00 here */
i.h.dl = (unsigned char)hdd; /* 0x80 for ide0, 0x81 for ide1 ..*/
i.x.si = (unsigned int)&dap; /* offset address of the parameter block*/
s.ds = _SS; /*segment address of the parameter block*/
int86x(0x13,&i,&o,&s);

if(o.x.cflag == 1) /* The carry flag is set on error */
{
/* Verify the error code with Ralf Brown */
printf("
Error #4: write_sector(): disk read returned #%X",o.h.ah);
}

---------------------------------

> i tried that also but it wasn`t working correctly . :-( don`t know
> why

It worked fine for me. Hack around.. you`d have done some mistake.

HTH :)

Cheers,
Joe

--
"Software is like sex; Its better when it is free"
-- Linus Torvalds

"The kingdom of heaven is spread out upon the earth,
and men do not see it" --Jesus, Gospel of Thomas 113

Visit:http://www.joesteeve.tk/
PS:> I hate HTML mail
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
China Wholesale - Electronics Products
Character Studio - Tutorials and Help