ata_bd.h

00001 /*
00002  * Copyright (c) 2009 Jiri Svoboda
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  *
00009  * - Redistributions of source code must retain the above copyright
00010  *   notice, this list of conditions and the following disclaimer.
00011  * - Redistributions in binary form must reproduce the above copyright
00012  *   notice, this list of conditions and the following disclaimer in the
00013  *   documentation and/or other materials provided with the distribution.
00014  * - The name of the author may not be used to endorse or promote products
00015  *   derived from this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00019  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00020  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00022  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00023  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00024  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00026  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  */
00028 
00035 #ifndef __ATA_BD_H__
00036 #define __ATA_BD_H__
00037 
00038 #include <sys/types.h>
00039 #include <fibril_synch.h>
00040 #include <str.h>
00041 
00043 typedef struct {
00044         uintptr_t cmd;  
00045         uintptr_t ctl;  
00046 } ata_base_t;
00047 
00049 enum ata_timeout {
00050         TIMEOUT_PROBE   =  100, /*  1 s */
00051         TIMEOUT_BSY     =  100, /*  1 s */
00052         TIMEOUT_DRDY    = 1000  /* 10 s */
00053 };
00054 
00055 enum ata_dev_type {
00056         ata_reg_dev,    /* Register device (no packet feature set support) */
00057         ata_pkt_dev     /* Packet device (supports packet feature set). */
00058 };
00059 
00061 enum rd_addr_mode {
00062         am_chs,         
00063         am_lba28,       
00064         am_lba48        
00065 };
00066 
00068 typedef struct {
00069         enum rd_addr_mode amode;
00070 
00071         union {
00073                 struct {
00074                         uint8_t sector;
00075                         uint8_t cyl_lo;
00076                         uint8_t cyl_hi;
00077                 };
00079                 struct {
00080                         uint8_t c0;
00081                         uint8_t c1;
00082                         uint8_t c2;
00083                         uint8_t c3;
00084                         uint8_t c4;
00085                         uint8_t c5;
00086                 };
00087         };
00088 
00090         uint8_t h;
00091 } block_coord_t;
00092 
00094 typedef struct {
00095         bool present;
00096 
00098         enum ata_dev_type dev_type;
00099 
00101         enum rd_addr_mode amode;
00102 
00103         /*
00104          * Geometry. Only valid if operating in CHS mode.
00105          */
00106         struct {
00107                 unsigned heads;
00108                 unsigned cylinders;
00109                 unsigned sectors;
00110         } geom;
00111 
00112         uint64_t blocks;
00113         size_t block_size;
00114 
00115         char model[STR_BOUNDS(40) + 1];
00116 
00117         fibril_mutex_t lock;
00118         devmap_handle_t devmap_handle;
00119 } disk_t;
00120 
00121 #endif
00122 

Generated on Thu Jun 2 07:45:49 2011 for HelenOS/USB by  doxygen 1.4.7