Home | History | Annotate | Download | only in boot

Lines Matching refs:wd

1 /*	$NetBSD: wd.c,v 1.5 2019/01/08 19:36:57 jdolecek Exp $	*/
42 static int wd_get_params(struct wd_softc *wd);
43 static int wdgetdisklabel(struct wd_softc *wd);
44 static void wdgetdefaultlabel(struct wd_softc *wd, struct disklabel *lp);
50 wd_get_params(struct wd_softc *wd)
55 if ((error = wdc_exec_identify(wd, buf)) != 0)
58 memcpy(&wd->sc_params, buf, sizeof wd->sc_params);
61 if ((wd->sc_params.atap_cmd2_en & ATA_CMD2_LBA48) != 0)
62 wd->sc_flags |= WDF_LBA48;
65 if ((wd->sc_params.atap_capabilities1 & WDC_CAP_LBA) != 0)
66 wd->sc_flags |= WDF_LBA;
68 if ((wd->sc_flags & WDF_LBA48) != 0) {
70 wd->sc_capacity =
71 ((uint64_t)wd->sc_params.atap_max_lba[3] << 48) |
72 ((uint64_t)wd->sc_params.atap_max_lba[2] << 32) |
73 ((uint64_t)wd->sc_params.atap_max_lba[1] << 16) |
74 ((uint64_t)wd->sc_params.atap_max_lba[0] << 0);
76 wd->sc_params.atap_max_lba[3],
77 wd->sc_params.atap_max_lba[2],
78 wd->sc_params.atap_max_lba[1],
79 wd->sc_params.atap_max_lba[0]));
80 wd->sc_capacity28 =
81 ((uint32_t)wd->sc_params.atap_capacity[1] << 16) |
82 ((uint32_t)wd->sc_params.atap_capacity[0] << 0);
84 wd->sc_params.atap_capacity[1],
85 wd->sc_params.atap_capacity[0]));
86 } else if ((wd->sc_flags & WDF_LBA) != 0) {
88 wd->sc_capacity = wd->sc_capacity28 =
89 ((uint32_t)wd->sc_params.atap_capacity[1] << 16) |
90 ((uint32_t)wd->sc_params.atap_capacity[0] << 0);
93 wd->sc_capacity = wd->sc_capacity28 =
94 wd->sc_params.atap_cylinders *
95 wd->sc_params.atap_heads *
96 wd->sc_params.atap_sectors;
98 DPRINTF(("wd->sc_capacity = %" PRId64 ", wd->sc_capacity28 = %d.\n",
99 wd->sc_capacity, wd->sc_capacity28));
108 wdgetdefaultlabel(struct wd_softc *wd, struct disklabel *lp)
114 lp->d_ntracks = wd->sc_params.atap_heads;
115 lp->d_nsectors = wd->sc_params.atap_sectors;
116 lp->d_ncylinders = wd->sc_params.atap_cylinders;
119 if (strcmp(wd->sc_params.atap_model, "ST506") == 0)
124 strncpy(lp->d_typename, wd->sc_params.atap_model, 16);
126 if (wd->sc_capacity > UINT32_MAX)
129 lp->d_secperunit = wd->sc_capacity;
156 wdgetdisklabel(struct wd_softc *wd)
163 wdgetdefaultlabel(wd, &wd->sc_label);
165 if (wdstrategy(wd, F_READ, LABELSECTOR, DEV_BSIZE, buf, &rsize))
168 if ((msg = getdisklabel(buf + LABELOFFSET, &wd->sc_label)))
169 printf("wd%d: getdisklabel: %s\n", wd->sc_unit, msg);
171 lp = &wd->sc_label;
174 if ((wd->sc_part >= lp->d_npartitions) ||
175 (lp->d_partitions[wd->sc_part].p_fstype == FS_UNUSED)) {
182 wd->sc_label.d_secsize,
183 wd->sc_label.d_nsectors,
184 wd->sc_label.d_ncylinders,
185 wd->sc_label.d_ntracks,
186 wd->sc_label.d_secpercyl));
200 struct wd_softc *wd;
209 wd = alloc(sizeof(struct wd_softc));
210 if (wd == NULL)
213 memset(wd, 0, sizeof(struct wd_softc));
215 if (wdc_init(wd, &unit) != 0)
218 wd->sc_part = part;
219 wd->sc_unit = unit;
221 if ((error = wd_get_params(wd)) != 0)
224 if ((error = wdgetdisklabel(wd)) != 0)
227 f->f_devdata = wd;
249 struct wd_softc *wd;
260 wd = f;
261 pp = &wd->sc_label.d_partitions[wd->sc_part];
263 nsect = howmany(size, wd->sc_label.d_secsize);
269 if ((error = wdc_exec_read(wd, WDCC_READ, blkno, buf)) != 0)
272 buf += wd->sc_label.d_secsize;