Exemplo n.º 1
0
/*
 * Get drive parameters through 'device identify' command.
 */
int
wd_get_params(struct wd_softc *wd)
{
	int error;
	uint8_t buf[DEV_BSIZE];

	if ((error = wdc_exec_identify(wd, buf)) != 0)
		return error;

	wd->sc_params = *(struct ataparams *)buf;

	/* 48-bit LBA addressing */
	if ((wd->sc_params.atap_cmd2_en & ATA_CMD2_LBA48) != 0) {
		DPRINTF(("Drive supports LBA48.\n"));
#if defined(_ENABLE_LBA48)
		wd->sc_flags |= WDF_LBA48;
#endif
	}

	/* Prior to ATA-4, LBA was optional. */
	if ((wd->sc_params.atap_capabilities1 & WDC_CAP_LBA) != 0) {
		DPRINTF(("Drive supports LBA.\n"));
		wd->sc_flags |= WDF_LBA;
	}

	return 0;
}
Exemplo n.º 2
0
/*
 * Get drive parameters through 'device identify' command.
 */
int
wd_get_params(struct wd_softc *wd)
{
	int error;
	uint8_t buf[DEV_BSIZE];

	if ((error = wdc_exec_identify(wd, buf)) != 0)
		return error;

	wd->sc_params = *(struct ataparams *)buf;

	/* 48-bit LBA addressing */
	if ((wd->sc_params.atap_cmd2_en & ATA_CMD2_LBA48) != 0)
		wd->sc_flags |= WDF_LBA48;

	/* Prior to ATA-4, LBA was optional. */
	if ((wd->sc_params.atap_capabilities1 & WDC_CAP_LBA) != 0)
		wd->sc_flags |= WDF_LBA;
	
	if ((wd->sc_flags & WDF_LBA48) != 0) {
		DPRINTF(("Drive supports LBA48.\n"));
		wd->sc_capacity =
		    ((uint64_t)wd->sc_params.atap_max_lba[3] << 48) |
		    ((uint64_t)wd->sc_params.atap_max_lba[2] << 32) |
		    ((uint64_t)wd->sc_params.atap_max_lba[1] << 16) |
		    ((uint64_t)wd->sc_params.atap_max_lba[0] <<  0);
		DPRINTF(("atap_max_lba = (0x%x, 0x%x, 0x%x, 0x%x)\n",
		    wd->sc_params.atap_max_lba[3],
		    wd->sc_params.atap_max_lba[2],
		    wd->sc_params.atap_max_lba[1],
		    wd->sc_params.atap_max_lba[0]));
		wd->sc_capacity28 =
		    ((uint32_t)wd->sc_params.atap_capacity[1] << 16) |
		    ((uint32_t)wd->sc_params.atap_capacity[0] <<  0);
		DPRINTF(("atap_capacity = (0x%x, 0x%x)\n",
		    wd->sc_params.atap_capacity[1],
		    wd->sc_params.atap_capacity[0]));
	} else if ((wd->sc_flags & WDF_LBA) != 0) {
		DPRINTF(("Drive supports LBA.\n"));
		wd->sc_capacity =
		    ((uint32_t)wd->sc_params.atap_capacity[1] << 16) |
		    ((uint32_t)wd->sc_params.atap_capacity[0] <<  0);
		wd->sc_capacity28 =
		    ((uint32_t)wd->sc_params.atap_capacity[1] << 16) |
		    ((uint32_t)wd->sc_params.atap_capacity[0] <<  0);
	} else {
		DPRINTF(("Drive doesn't support LBA; using CHS.\n"));
		wd->sc_capacity = wd->sc_capacity28 =
		    wd->sc_params.atap_cylinders *
		    wd->sc_params.atap_heads *
		    wd->sc_params.atap_sectors;
	}
	DPRINTF(("wd->sc_capacity = %" PRId64 ", wd->sc_capacity28 = %d.\n",
	    wd->sc_capacity, wd->sc_capacity28));

	return 0;
}