OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [orpmon/] [services/] [dos.c] - Diff between revs 922 and 1020

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 922 Rev 1020
Line 31... Line 31...
/*
/*
  D O S _ O P E N
  D O S _ O P E N
*/
*/
int dos_open(struct dosparam *params)
int dos_open(struct dosparam *params)
{
{
  int error;
  int error, start_sector, partition;
  unsigned char buf[512];
  unsigned char buf[512];
 
 
  struct inode *inode = &params->inode;
  struct inode *inode = &params->inode;
  struct file  *filp  = &params->filp;
  struct file  *filp  = &params->filp;
  struct request *request = &params->request;
  struct request *request = &params->request;
 
 
  if( (error = ata_open(inode, filp)) )
  if( (error = ata_open(inode, filp)) )
    return error;
    return error;
 
 
 
 
  /* device opened, read boot-sector                                  */
  /* device opened, read MBR                                          */
  request->cmd = READ;
  request->cmd = READ;
  request->sector = 0;
  request->sector = 0;
  request->nr_sectors = 1;
  request->nr_sectors = 1;
  request->buffer = buf;
  request->buffer = buf;
 
 
 
  /* skip bootload (446) bytes                                        */
 
  /* currently only support the first partition (partition 4)         */
 
  /* This is OK, because CompactFLASH devices only have 1 partition   */
 
  if ( (error = ata_request(inode, filp, request)) )
 
    return error;
 
 
 
  partition = 0;    /* first partition                                */
 
  partition *= 16;  /* 16 bytes per partition table                   */
 
  partition += 446; /* skip bootloader, go to partition table         */
 
  start_sector = buf[partition +11] << 24 |
 
                 buf[partition +10] << 16 |
 
                 buf[partition +9] << 8   |
 
                 buf[partition +8];
 
 
 
  /* device opened, read boot-sector                                  */
 
  request->cmd = READ;
 
  request->sector = start_sector;
 
  request->nr_sectors = 1;
 
  request->buffer = buf;
 
 
  if ( (error = ata_request(inode, filp, request)) )
  if ( (error = ata_request(inode, filp, request)) )
    return error;
    return error;
 
 
  /* get the necessary data from the boot-sector                      */
  /* get the necessary data from the boot-sector                      */
  params->bytes_per_sector = (buf[12]<<8) | buf[11];
  params->bytes_per_sector = (buf[12]<<8) | buf[11];
Line 60... Line 80...
  params->root_entries = (buf[18]<<8) | buf[17];
  params->root_entries = (buf[18]<<8) | buf[17];
  params->sectors_per_cluster = buf[13];
  params->sectors_per_cluster = buf[13];
 
 
 
 
  /* set start of current directory to start of root-directory        */
  /* set start of current directory to start of root-directory        */
  params->ssector = params->fats * params->sectors_per_fat +1;
  params->ssector = start_sector + params->fats * params->sectors_per_fat +1;
 
 
  /* set current sector to start of root-directory                    */
  /* set current sector to start of root-directory                    */
  params->csector = params->ssector;
  params->csector = params->ssector;
 
 
  /* set start-entry number                                           */
  /* set start-entry number                                           */

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.