hd.h

Go to the documentation of this file.
00001 /*****************************************************************************************
00002  Copyright (c) 2002-2004 The UbixOS Project
00003  All rights reserved.
00004 
00005  Redistribution and use in source and binary forms, with or without modification, are
00006  permitted provided that the following conditions are met:
00007 
00008  Redistributions of source code must retain the above copyright notice, this list of
00009  conditions, the following disclaimer and the list of authors.  Redistributions in binary
00010  form must reproduce the above copyright notice, this list of conditions, the following
00011  disclaimer and the list of authors in the documentation and/or other materials provided
00012  with the distribution. Neither the name of the UbixOS Project nor the names of its
00013  contributors may be used to endorse or promote products derived from this software
00014  without specific prior written permission.
00015 
00016  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
00017  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00018  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
00019  THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00020  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
00021  OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00022  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
00023  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00024  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00025 
00026  $Id: hd_8h-source.html 88 2016-01-12 00:11:29Z reddawg $
00027 
00028 *****************************************************************************************/
00029 
00030 #ifndef _HD_H
00031 #define _HD_H
00032 
00033 #include <ubixfs/ubixfs.h>
00034 
00035 #define hdData     0x0
00036 #define hdError    0x1
00037 #define hdSecCount 0x2
00038 #define hdSecNum   0x3
00039 #define hdCylLow   0x4
00040 #define hdCylHi    0x5
00041 #define hdHead     0x6
00042 #define hdStat     0x7
00043 #define hdCmd      0x7
00044 
00045 
00046 struct driveInfo {
00047   struct driveDiskLabel *diskLabel;
00048   char hdSector[512];
00049   char hdEnable;
00050   char hdDev;
00051   char hdFlags;
00052   char hdShift;
00053   long hdMask;
00054   long hdMulti;
00055   long hdPort;
00056   long hdSize;
00057   long hdCalc;
00058   long parOffset;
00059   };
00060 
00061 int initHardDisk();
00062 void hdWrite(struct driveInfo *hdd,void *,uInt32,uInt32);
00063 void hdRead(struct driveInfo *hdd,void *,uInt32,uInt32);
00064 int hdReset();
00065 int hdIoctl();
00066 int hdStart();
00067 int hdStop();
00068 int hdStandby();
00069 int hdInit(struct device_node *dev);
00070 
00071 struct dos_partition {
00072   unsigned char   dp_flag;        /* bootstrap flags */
00073   unsigned char   dp_shd;         /* starting head */
00074   unsigned char   dp_ssect;       /* starting sector */
00075   unsigned char   dp_scyl;        /* starting cylinder */
00076   unsigned char   dp_type;         /* partition type */
00077   unsigned char   dp_ehd;         /* end head */
00078   unsigned char   dp_esect;       /* end sector */
00079   unsigned char   dp_ecyl;        /* end cylinder */
00080   uInt32       dp_start;       /* absolute starting sector number */
00081   uInt32       dp_size;        /* partition size in sectors */
00082   };
00083 
00084 #define MAXPARTITIONS   8
00085 
00086 struct bsd_disklabel {
00087         uint32_t d_magic;              /* the magic number */
00088         u_int16_t d_type;               /* drive type */
00089         u_int16_t d_subtype;            /* controller/d_type specific */
00090         char      d_typename[16];       /* type name, e.g. "eagle" */
00091 
00092         char      d_packname[16];       /* pack identifier */
00093 
00094                         /* disk geometry: */
00095         uint32_t d_secsize;            /* # of bytes per sector */
00096         uint32_t d_nsectors;           /* # of data sectors per track */
00097         uint32_t d_ntracks;            /* # of tracks per cylinder */
00098         uint32_t d_ncylinders;         /* # of data cylinders per unit */
00099         uint32_t d_secpercyl;          /* # of data sectors per cylinder */
00100         uint32_t d_secperunit;         /* # of data sectors per unit */
00101 
00102         /*
00103          * Spares (bad sector replacements) below are not counted in
00104          * d_nsectors or d_secpercyl.  Spare sectors are assumed to
00105          * be physical sectors which occupy space at the end of each
00106          * track and/or cylinder.
00107          */
00108         u_int16_t d_sparespertrack;     /* # of spare sectors per track */
00109         u_int16_t d_sparespercyl;       /* # of spare sectors per cylinder */
00110         /*
00111          * Alternate cylinders include maintenance, replacement, configuration
00112          * description areas, etc.
00113          */
00114         uint32_t d_acylinders;         /* # of alt. cylinders per unit */
00115 
00116                         /* hardware characteristics: */
00117         /*
00118          * d_interleave, d_trackskew and d_cylskew describe perturbations
00119          * in the media format used to compensate for a slow controller.
00120          * Interleave is physical sector interleave, set up by the
00121          * formatter or controller when formatting.  When interleaving is
00122          * in use, logically adjacent sectors are not physically
00123          * contiguous, but instead are separated by some number of
00124          * sectors.  It is specified as the ratio of physical sectors
00125          * traversed per logical sector.  Thus an interleave of 1:1
00126          * implies contiguous layout, while 2:1 implies that logical
00127          * sector 0 is separated by one sector from logical sector 1.
00128          * d_trackskew is the offset of sector 0 on track N relative to
00129          * sector 0 on track N-1 on the same cylinder.  Finally, d_cylskew
00130          * is the offset of sector 0 on cylinder N relative to sector 0
00131          * on cylinder N-1.
00132          */
00133         u_int16_t d_rpm;                /* rotational speed */
00134         u_int16_t d_interleave;         /* hardware sector interleave */
00135         u_int16_t d_trackskew;          /* sector 0 skew, per track */
00136         u_int16_t d_cylskew;            /* sector 0 skew, per cylinder */
00137         uint32_t d_headswitch;         /* head switch time, usec */
00138         uint32_t d_trkseek;            /* track-to-track seek, usec */
00139         uint32_t d_flags;              /* generic flags */
00140 #define NDDATA 5
00141         uint32_t d_drivedata[NDDATA];  /* drive-type specific information */
00142 #define NSPARE 5
00143         uint32_t d_spare[NSPARE];      /* reserved for future use */
00144         uint32_t d_magic2;             /* the magic number (again) */
00145         u_int16_t d_checksum;           /* xor of data incl. partitions */
00146 
00147                         /* filesystem and partition information: */
00148         u_int16_t d_npartitions;        /* number of partitions in following */
00149         uint32_t d_bbsize;             /* size of boot area at sn0, bytes */
00150         uint32_t d_sbsize;             /* max size of fs superblock, bytes */
00151         struct partition {              /* the partition table */
00152                 uint32_t p_size;       /* number of sectors in partition */
00153                 uint32_t p_offset;     /* starting sector */
00154                 uint32_t p_fsize;      /* filesystem basic fragment size */
00155                 u_int8_t p_fstype;      /* filesystem type, see below */
00156                 u_int8_t p_frag;        /* filesystem fragments per block */
00157                 u_int16_t p_cpg;        /* filesystem cylinders per group */
00158         } d_partitions[MAXPARTITIONS];  /* actually may be more */
00159 };
00160 
00161 static const char *fstypenames[] = {
00162         "unused",
00163         "swap",
00164         "Version 6",
00165         "Version 7",
00166         "System V",
00167         "4.1BSD",
00168         "Eighth Edition",
00169         "4.2BSD",
00170         "MSDOS",
00171         "4.4LFS",
00172         "unknown",
00173         "HPFS",
00174         "ISO9660",
00175         "boot",
00176         "vinum",
00177         "raid",
00178         "?",
00179         "?",
00180         "?",
00181         "?",
00182         "jfs",
00183         NULL
00184 };
00185 
00186 #endif
00187 
00188 /***
00189  $Log: hd_8h-source.html,v $
00189  Revision 1.7  2006/12/15 17:47:05  reddawg
00189  Updates
00189 
00190  Revision 1.2  2006/10/09 02:58:05  reddawg
00191  Fixing UFS
00192 
00193  Revision 1.1.1.1  2006/06/01 12:46:14  reddawg
00194  ubix2
00195 
00196  Revision 1.2  2005/10/12 00:13:37  reddawg
00197  Removed
00198 
00199  Revision 1.1.1.1  2005/09/26 17:23:50  reddawg
00200  no message
00201 
00202  Revision 1.7  2004/08/15 00:33:02  reddawg
00203  Wow the ide driver works again
00204 
00205  Revision 1.6  2004/07/21 10:02:09  reddawg
00206  devfs: renamed functions
00207  device system: renamed functions
00208  fdc: fixed a few potential bugs and cleaned up some unused variables
00209  strol: fixed definition
00210  endtask: made it print out freepage debug info
00211  kmalloc: fixed a huge memory leak we had some unhandled descriptor insertion so some descriptors were lost
00212  ld: fixed a pointer conversion
00213  file: cleaned up a few unused variables
00214  sched: broke task deletion
00215  kprintf: fixed ogPrintf definition
00216 
00217  Revision 1.5  2004/05/21 15:05:07  reddawg
00218  Cleaned up
00219 
00220 
00221  END
00222  ***/

Generated on Fri Dec 15 11:18:54 2006 for UbixOS V2 by  doxygen 1.4.7