ata_info.h

Go to the documentation of this file.
00001 /* 
00002     Copyright (c) 2002-04, Thomas Kurschel. All rights reserved.
00003     Distributed under the terms of the MIT License.
00004     
00005     Part of ATA bus manager
00006     
00007 */
00008 
00009 #ifndef _ATA_INFO_H
00010 #define _ATA_INFO_H
00011 
00012 #include <lendian_bitfield.h>
00013 #include <Drivers.h>
00014 
00015 /*
00016     ioctl() codes specific to ATA devices.
00017     Those existed before but were kept private (values are not the smartest).
00018     Used in ideinfo and idestatus
00019 */
00020 
00021 enum {
00022     B_ATA_GET_DEVICE_INFO = B_DEVICE_OP_CODES_END + 1,  // ata_device_infoblock *
00023     B_ATA_GET_DEVICE_STATUS                 // ata_device_status *
00024 };
00025 
00026 /*
00027     Definition of response to ATA_CMD_IDENTIFY_DEVICE or 
00028     ATA_CMD_IDENTIFY_PACKET_DEVICE
00029     Additionally, what is filled in by B_ATA_GET_DEVICE_INFO
00030     
00031     When a new entry is inserted, add its offset in hex
00032     and its index in decimal as a remark. Without that, you
00033     have a rough time when you messed up the offsets.
00034 */
00035 
00036 // must be 512 bytes!!!
00037 typedef struct tagdevice_infoblock {
00038     union {                     // 0 general configuration
00039         struct {
00040             LBITFIELD8 (
00041                 _0_res1                         : 1,
00042                 _0_ret1                         : 1,
00043                 response_incomplete             : 1,
00044                 _0_ret2                         : 3,
00045                 removable_controller_or_media   : 1,
00046                 removable_media                 : 1,
00047                 _0_ret3                         : 7,
00048                 ATA                             : 1  // 0 - is ATA!
00049             );
00050         } ata;
00051         struct {
00052             LBITFIELD8 (
00053                 packet_size                     : 2, // 0 - 12 bytes, 1 - 16 bytes
00054                 response_incomplete             : 1,
00055                 _0_res2                         : 2,
00056                 drq_speed                       : 2, // 0 - 3ms, 1 - IRQ, 2 - 50µs
00057                 removable_media                 : 1,
00058                 type                            : 5,
00059                 _0_res13                        : 1,
00060                 ATAPI                           : 2  // 2 - is ATAPI
00061             );
00062         } atapi;
00063     } _0;
00064     uint16 cylinders;           // 2
00065     uint16 dummy1;              // 4
00066     uint16 heads;               // 6
00067     uint16 dummy2[2];           // 8
00068     uint16 sectors;             // 0c
00069     uint16 dummy3[3];           // 0e
00070     char serial_number[20];     // 14
00071     uint16 dummy4[3];           // 28
00072     char firmware_version[8];   // 2e
00073     char model_number[40];      // 36
00074     uint16 dummy5[2];           // 5e
00075     LBITFIELD5 (                // 62 (49) capabilities
00076         _49_ret1            : 8,
00077         DMA_supported       : 1,
00078         LBA_supported       : 1,
00079         IORDY_can_disable   : 1,
00080         IORDY_supported     : 1
00081     );
00082     
00083     uint16 dummy6[1];           // 64
00084     LBITFIELD2 (                // 66 (51) obsolete: PIO modes?
00085         _51_obs1            : 8,
00086         PIO_mode            : 8
00087     );
00088     uint16 dummy7[1];           // 68
00089     
00090     
00091     LBITFIELD3 (                // 6a (53) validity
00092         _54_58_valid        : 1,
00093         _64_70_valid        : 1,
00094         _88_valid           : 1
00095     );
00096     uint16 current_cylinders;   // 6c (54)
00097     uint16 current_heads;       // 6e
00098     uint16 current_sectors;     // 70
00099     
00100     uint16 capacity_low;        // 72 (57) ALIGNMENT SPLIT - don't merge
00101     uint16 capacity_high;
00102     
00103     uint16 dummy8[1];
00104     
00105     uint32 LBA_total_sectors;   // 78 (60)
00106     uint16 dummy9[1];           // 7c
00107     
00108     LBITFIELD7 (                // 7e (63) MDMA modes
00109         MDMA0_supported     : 1,
00110         MDMA1_supported     : 1,
00111         MDMA2_supported     : 1,
00112         _63_res1            : 5,
00113         MDMA0_selected      : 1,
00114         MDMA1_selected      : 1,
00115         MDMA2_selected      : 1
00116     );
00117     uint16 dummy10[11];         // 80
00118     
00119     LBITFIELD2 (                // 96 (75)
00120         queue_depth         : 5,
00121         _75_res1            : 9
00122     );
00123     uint16 dummy11[6];          // 98
00124     
00125     LBITFIELD16 (               // a4 (82) supported_command_set
00126         SMART_supported             : 1,
00127         security_mode_supported     : 1,
00128         removable_media_supported   : 1,
00129         PM_supported                : 1,
00130         _82_fixed                   : 1,    // must be 0 for ATA, 1 for ATAPI
00131         write_cache_supported       : 1,
00132         look_ahead_supported        : 1,
00133         RELEASE_irq_supported       : 1,
00134         
00135         SERVICE_irq_supported       : 1,
00136         DEVICE_RESET_supported      : 1,
00137         HPA_supported               : 1,
00138         _82_obs1                    : 1,
00139         WRITE_BUFFER_supported      : 1,
00140         READ_BUFFER_supported       : 1,
00141         NOP_supported               : 1,
00142         _82_obs2                    : 1
00143     );
00144     LBITFIELD15 (               // a6 (83) supported_command_sets
00145         DOWNLOAD_MICROCODE_supported        : 1,
00146         DMA_QUEUED_supported                : 1,
00147         CFA_supported                       : 1,
00148         APM_supported                       : 1,
00149         RMSN_supported                      : 1,
00150         power_up_in_stand_by_supported      : 1,
00151         SET_FEATURES_on_power_up_required   : 1,
00152         reserved_boot_area_supported        : 1,
00153         SET_MAX_security_supported          : 1,
00154         auto_acustic_managemene_supported   : 1,
00155         _48_bit_addresses_supported         : 1,
00156         device_conf_overlay_supported       : 1,
00157         FLUSH_CACHE_supported               : 1,
00158         FLUSH_CACHE_EXT_supported           : 1,
00159         _83_fixed                           : 2 // must be 1 
00160     );
00161     
00162     uint16 dummy12[4];          // a8 (84)
00163     LBITFIELD15 (               // b0 (88) UDMA modes
00164         UDMA0_supported     : 1,
00165         UDMA1_supported     : 1,
00166         UDMA2_supported     : 1,
00167         UDMA3_supported     : 1,
00168         UDMA4_supported     : 1,
00169         UDMA5_supported     : 1,
00170         UDMA6_supported     : 1,    // !guessed
00171         _88_res1            : 1,
00172         UDMA0_selected      : 1,
00173         UDMA1_selected      : 1,
00174         UDMA2_selected      : 1,
00175         UDMA3_selected      : 1,
00176         UDMA4_selected      : 1,
00177         UDMA5_selected      : 1,
00178         UDMA6_selected      : 1
00179     );
00180     
00181     uint16 dummy89[11];         // b2 (89)
00182     uint64 LBA48_total_sectors; // c8 (100)
00183     uint16 dummy102[22];        // cc (104)
00184     
00185     LBITFIELD2 (                // fc (126) 
00186         last_lun            : 2,
00187         _126_res2           : 14
00188     );
00189     LBITFIELD4 (                // fe (127) RMSN support
00190         _127_RMSN_support   : 2,// 0 = not supported, 1 = supported, 3, 4 = reserved
00191         _127_res2           : 6,
00192         device_write_protect: 2,
00193         _127_res9           : 6
00194     );
00195     uint16 dummy14[128];        // 100 (128)
00196 } ata_device_infoblock;
00197 
00198 /*
00199     
00200 */
00201 
00202 enum {
00203     B_ATA_DMA_STATUS_UNSUPPORTED,
00204     B_ATA_DMA_STATUS_ENABLED,
00205     B_ATA_DMA_STATUS_DISABLED_USER,
00206     B_ATA_DMA_STATUS_DISABLED_SAFE_MODE,
00207     B_ATA_DMA_STATUS_UNSUPPORTED_CONTROLLER,
00208     B_ATA_DMA_STATUS_DISABLED_DRIVER_CONFIG,
00209     B_ATA_DMA_STATUS_DISABLED_DRIVER_FAILURE
00210 };
00211 
00212 typedef struct tagata_device_status {
00213         uint8 version;  // 1
00214         uint8 dma_status;
00215         uint8 pio_mode;
00216         uint8 dma_mode;
00217 } _PACKED ata_device_status;
00218 
00219 
00220 #endif /* _ATA_INFO_H */

Copyright 2005 by yellowTAB GmbH, Be Inc., Palm Source Inc. and their respective legal successors
All rights reserved.