Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Reading / Writing the Master Boot Record with VxWorks.

433 views
Skip to first unread message

martinc...@my-deja.com

unread,
Nov 3, 1999, 3:00:00 AM11/3/99
to

Hi everyone,

I have been looking into ways of reading the 512 bytes of info that
is located at head 0, cyclinder 0, sector 1, ie: the Master Boot Record
in order to browse/modify the partition information. I have done this
successfully in DOS but so far have failed with my VxWorks attempts.

Can anyone point me in the right direction?

Thanks,
Martin.


Sent via Deja.com http://www.deja.com/
Before you buy.

Thomas Rahn

unread,
Nov 3, 1999, 3:00:00 AM11/3/99
to
--
Thomas Rahn

MS MacroSystem GmbH
Entwicklungsbüro
Holzstr. 1
D-64283 Darmstadt

tel.: +49 6151 272579
fax.: +49 6151 272577

Thomas Rahn

unread,
Nov 3, 1999, 3:00:00 AM11/3/99
to
Hi,

reading / writing the MBR of a hard disk requires access to the first
block of the disk. If the dos file system is mounted on a hard disk
partitioned with the DOS fdisk utility or similar, the standard VxWorks
functions mount the device at a block offset given in the MBR partition
table.

You will have to use ataRawio() to directly access the disk or mount
another dosFs / rawFs device with no block offset.

The function ataRawio() expects the controller / drive number
and a structure with the block (in CHS), buffers, and direction.

I have a done a partitioning tool myself using this function.
You will have to insert a boot loader program in the MBR if you
rely on a standard PC BIOS (we do not).

There is one further drawback depending on the dosFs lib you use:
you format a mounted partition with the dosFs format, but the
bootblock of this partition is not initialized. However, there
are components relying on some filled entries in the partition
bootblock (I don't recall which tool it is: dosFs Lib, vxLoader,..)

You will have to modify the data of the block:
// insert jump to begin of code
secBuf[0] = 0xeb;
secBuf[1] = 0x3c;
secBuf[2] = 0x90;

// this is the offset of the partition to the start of the disk
*(ULONG*)&(secBuf[DOS_BOOT_NHIDDEN_SECS])= offset;

// insert id string
bcopy (VXSYS_ID, (char *)&secBuf[0x03], DOS_SYS_ID_LEN);

// modify drive number "c:" is 0x80
secBuf[0x1d2] = 0x80;

We are working with some dosFs 2.0 EAR and do not require this
patch anymore ...

Thomas Rahn

(sorry for empty message, i am clicking to fast)

Harvey Taylor

unread,
Nov 3, 1999, 3:00:00 AM11/3/99
to
martinc...@my-deja.com wrote:
> I have been looking into ways of reading the 512 bytes of info that
> is located at head 0, cyclinder 0, sector 1, ie: the Master Boot Record
>

Look at how ataRawio is used in usrAtaConfig.
That should answer all your questions.
<l8r>
-het


--
"...the games grown men play in corporate life I find
revolting and I cannot personally participate."
- Seymour Cray [in his letter of resignation from CDC]

Harvey Taylor Internet: h...@despam.portal.ca

Lanzl Georg

unread,
Nov 9, 1999, 3:00:00 AM11/9/99
to
Hi Martin

I've used ataRawIo() to do this (defined in atadrv.h )
Here is my example code.

#include <vxworks.h>
#include <syslib.h>
#include <stdio.h>
#include <../h/drv/hdisk/atadrv.h>

typedef struct _TBootSector
{
unsigned char bRawData[512]; /* */
}TBootSector;

STATUS GetMasterBootRecord(int ctrl, int drive, TBootSector *pMBR)
{
ATA_RAW AtaRaw;


AtaRaw.cylinder =0; /* cylinder (0 -> (cylindres-1)) */
AtaRaw.head = 0; /* head (0 -> (heads-1)) */
AtaRaw.sector = 1; /* sector (1 -> sectorsTrack) */
AtaRaw.pBuf = pMBR->bRawData; /* pointer to buffer (bytesSector *
nSecs) */
AtaRaw.nSecs = 1; /* number of sectors (1 -> sectorsTrack) */
AtaRaw.direction = 0; /* read=0, write=1 */

if( ataRawio(ctrl, drive,&AtaRaw) != OK )
{
return( ERROR );
}

return( OK );
}

Have fun
Georg

--
Bernecker & Rainer Industrieelektronik Gmbh.
Georg Lanzl
Bernecker & Rainer Industrieelektronik Gmbh.
http://www.br-automation.com

<martinc...@my-deja.com> wrote in message
news:7vo0t2$rka$1...@nnrp1.deja.com...
>
>
> Hi everyone,


>
> I have been looking into ways of reading the 512 bytes of info that
> is located at head 0, cyclinder 0, sector 1, ie: the Master Boot Record

0 new messages