source: mainline/uspace/srv/bd/ata_bd/ata_bd.h@ 47b7006

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 47b7006 was e092dc5, checked in by Jiri Svoboda <jiri@…>, 15 years ago

Fix incorrect control block base address. Add base adresses for three more legacy ATA controllers. Allow selecting ATA controller via command line argument.

  • Property mode set to 100644
File size: 2.9 KB
Line 
1/*
2 * Copyright (c) 2009 Jiri Svoboda
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup bd
30 * @{
31 */
32/** @file ATA driver definitions.
33 */
34
35#ifndef __ATA_BD_H__
36#define __ATA_BD_H__
37
38#include <sys/types.h>
39#include <fibril_synch.h>
40#include <str.h>
41
42/** Base addresses for ATA I/O blocks. */
43typedef struct {
44 uintptr_t cmd; /**< Command block base address. */
45 uintptr_t ctl; /**< Control block base address. */
46} ata_base_t;
47
48/** Timeout definitions. Unit is 10 ms. */
49enum ata_timeout {
50 TIMEOUT_PROBE = 100, /* 1 s */
51 TIMEOUT_BSY = 100, /* 1 s */
52 TIMEOUT_DRDY = 1000 /* 10 s */
53};
54
55/** Block addressing mode. */
56enum addr_mode {
57 am_chs, /**< CHS block addressing */
58 am_lba28, /**< LBA-28 block addressing */
59 am_lba48 /**< LBA-48 block addressing */
60};
61
62/** Block coordinates */
63typedef struct {
64 /** Addressing mode used */
65 enum addr_mode amode;
66
67 union {
68 /** CHS coordinates */
69 struct {
70 uint8_t sector;
71 uint8_t cyl_lo;
72 uint8_t cyl_hi;
73 };
74 /** LBA coordinates */
75 struct {
76 uint8_t c0;
77 uint8_t c1;
78 uint8_t c2;
79 uint8_t c3;
80 uint8_t c4;
81 uint8_t c5;
82 };
83 };
84
85 /** Lower 4 bits for device/head register */
86 uint8_t h;
87} block_coord_t;
88
89/** ATA device state structure. */
90typedef struct {
91 bool present;
92 enum addr_mode amode;
93
94 /*
95 * Geometry. Only valid if operating in CHS mode.
96 */
97 struct {
98 unsigned heads;
99 unsigned cylinders;
100 unsigned sectors;
101 } geom;
102
103 uint64_t blocks;
104
105 char model[STR_BOUNDS(40) + 1];
106
107 fibril_mutex_t lock;
108 devmap_handle_t devmap_handle;
109} disk_t;
110
111#endif
112
113/** @}
114 */
Note: See TracBrowser for help on using the repository browser.