Sync usage with man page.
[netbsd-mini2440.git] / sys / arch / cobalt / stand / boot / wdvar.h
blob9e937beceb7edafb9a9180f256c87aa2f83e390e
1 /* $NetBSD: wdvar.h,v 1.6.38.1 2007/10/03 19:23:05 garbled Exp $ */
3 /*-
4 * Copyright (c) 2003 The NetBSD Foundation, Inc.
5 * Copyright (c) 2001 Dynarc AB, Sweden. All rights reserved.
7 * This code is derived from software written by Anders Magnusson,
8 * ragge@ludd.luth.se
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #ifndef _STAND_WDVAR_H
34 #define _STAND_WDVAR_H
36 #include <dev/ic/wdcreg.h>
37 #include <dev/ata/atareg.h>
38 #include <dev/pci/pciidereg.h>
40 #include <mips/cpuregs.h>
42 #include <sys/disklabel.h>
43 #include <sys/bootblock.h>
45 #define WDC_TIMEOUT 2000000
46 #define PCIIDE_CHANNEL_NDEV 2
47 #define NUNITS (PCIIDE_CHANNEL_NDEV * PCIIDE_NUM_CHANNELS)
48 #define WDC_NPORTS 8 /* XXX */
49 #define WDC_NSHADOWREG 2 /* XXX */
51 struct wdc_channel {
52 volatile uint8_t *c_cmdbase;
53 volatile uint8_t *c_ctlbase;
54 volatile uint8_t *c_cmdreg[WDC_NPORTS + WDC_NSHADOWREG];
55 volatile uint16_t *c_data;
57 uint8_t compatchan;
60 #define WDC_READ_REG(chp, reg) *(chp)->c_cmdreg[(reg)]
61 #define WDC_WRITE_REG(chp, reg, val) *(chp)->c_cmdreg[(reg)] = (val)
62 #define WDC_READ_CTLREG(chp, reg) (chp)->c_ctlbase[(reg)]
63 #define WDC_WRITE_CTLREG(chp, reg, val) (chp)->c_ctlbase[(reg)] = (val)
64 #define WDC_READ_DATA(chp) *(chp)->c_data
66 struct wd_softc {
67 #define WDF_LBA 0x0001
68 #define WDF_LBA48 0x0002
69 uint16_t sc_flags;
71 u_int sc_part;
72 u_int sc_unit;
74 uint64_t sc_capacity;
76 struct ataparams sc_params;
77 struct disklabel sc_label;
78 struct wdc_channel sc_channel;
81 struct wdc_command {
82 uint8_t drive; /* drive id */
84 uint8_t r_command; /* Parameters to upload to registers */
85 uint8_t r_head;
86 uint16_t r_cyl;
87 uint8_t r_sector;
88 uint8_t r_count;
89 uint8_t r_precomp;
91 uint16_t bcount;
92 void *data;
94 uint64_t r_blkno;
97 int wdc_init(struct wd_softc *, u_int *);
98 int wdccommand(struct wd_softc *, struct wdc_command *);
99 int wdccommandext(struct wd_softc *, struct wdc_command *);
100 int wdc_exec_read(struct wd_softc *, uint8_t, daddr_t, void *);
101 int wdc_exec_identify(struct wd_softc *, void *);
103 int pciide_init(struct wdc_channel *, u_int *);
105 #endif /* _STAND_WDVAR_H */