Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 76213
b: refs/heads/master
c: 7a3b751
h: refs/heads/master
i:
  76211: 1f8d93e
v: v3
  • Loading branch information
Bartlomiej Zolnierkiewicz committed Jan 25, 2008
1 parent 4ffeb78 commit 27e5e91
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 72 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 650d841d9e053a618dd8ce753422f91b493cf2f6
refs/heads/master: 7a3b7512d0d7e78353e99f4538eb6d3354019d92
103 changes: 32 additions & 71 deletions trunk/drivers/ide/ide-disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,50 +307,33 @@ static ide_startstop_t ide_do_rw_disk (ide_drive_t *drive, struct request *rq, s
* Queries for true maximum capacity of the drive.
* Returns maximum LBA address (> 0) of the drive, 0 if failed.
*/
static unsigned long idedisk_read_native_max_address(ide_drive_t *drive)
static u64 idedisk_read_native_max_address(ide_drive_t *drive, int lba48)
{
ide_task_t args;
struct ide_taskfile *tf = &args.tf;
unsigned long addr = 0;
u64 addr = 0;

/* Create IDE/ATA command request structure */
memset(&args, 0, sizeof(ide_task_t));
if (lba48)
tf->command = WIN_READ_NATIVE_MAX_EXT;
else
tf->command = WIN_READ_NATIVE_MAX;
tf->device = ATA_LBA;
tf->command = WIN_READ_NATIVE_MAX;
args.command_type = IDE_DRIVE_TASK_NO_DATA;
args.handler = &task_no_data_intr;
/* submit command request */
ide_raw_taskfile(drive, &args, NULL);

/* if OK, compute maximum address value */
if ((tf->status & 0x01) == 0) {
addr = ((tf->device & 0xf) << 24) |
(tf->lbah << 16) | (tf->lbam << 8) | tf->lbal;
addr++; /* since the return value is (maxlba - 1), we add 1 */
}
return addr;
}

static unsigned long long idedisk_read_native_max_address_ext(ide_drive_t *drive)
{
ide_task_t args;
struct ide_taskfile *tf = &args.tf;
unsigned long long addr = 0;

/* Create IDE/ATA command request structure */
memset(&args, 0, sizeof(ide_task_t));
tf->device = ATA_LBA;
tf->command = WIN_READ_NATIVE_MAX_EXT;
args.command_type = IDE_DRIVE_TASK_NO_DATA;
args.handler = &task_no_data_intr;
/* submit command request */
ide_raw_taskfile(drive, &args, NULL);

/* if OK, compute maximum address value */
if ((tf->status & 0x01) == 0) {
u32 high, low;

high = (tf->hob_lbah << 16) | (tf->hob_lbam << 8) | tf->hob_lbal;
if (lba48)
high = (tf->hob_lbah << 16) | (tf->hob_lbam << 8) |
tf->hob_lbal;
else
high = tf->device & 0xf;
low = (tf->lbah << 16) | (tf->lbam << 8) | tf->lbal;
addr = ((__u64)high << 24) | low;
addr++; /* since the return value is (maxlba - 1), we add 1 */
Expand All @@ -362,50 +345,28 @@ static unsigned long long idedisk_read_native_max_address_ext(ide_drive_t *drive
* Sets maximum virtual LBA address of the drive.
* Returns new maximum virtual LBA address (> 0) or 0 on failure.
*/
static unsigned long idedisk_set_max_address(ide_drive_t *drive, unsigned long addr_req)
static u64 idedisk_set_max_address(ide_drive_t *drive, u64 addr_req, int lba48)
{
ide_task_t args;
struct ide_taskfile *tf = &args.tf;
unsigned long addr_set = 0;

addr_req--;
/* Create IDE/ATA command request structure */
memset(&args, 0, sizeof(ide_task_t));
tf->lbal = (addr_req >> 0) & 0xff;
tf->lbam = (addr_req >> 8) & 0xff;
tf->lbah = (addr_req >> 16) & 0xff;
tf->device = ((addr_req >> 24) & 0x0f) | ATA_LBA;
tf->command = WIN_SET_MAX;
args.command_type = IDE_DRIVE_TASK_NO_DATA;
args.handler = &task_no_data_intr;
/* submit command request */
ide_raw_taskfile(drive, &args, NULL);
/* if OK, read new maximum address value */
if ((tf->status & 0x01) == 0) {
addr_set = ((tf->device & 0xf) << 24) |
(tf->lbah << 16) | (tf->lbam << 8) | tf->lbal;
addr_set++;
}
return addr_set;
}

static unsigned long long idedisk_set_max_address_ext(ide_drive_t *drive, unsigned long long addr_req)
{
ide_task_t args;
struct ide_taskfile *tf = &args.tf;
unsigned long long addr_set = 0;
u64 addr_set = 0;

addr_req--;
/* Create IDE/ATA command request structure */
memset(&args, 0, sizeof(ide_task_t));
tf->lbal = (addr_req >> 0) & 0xff;
tf->lbam = (addr_req >>= 8) & 0xff;
tf->lbah = (addr_req >>= 8) & 0xff;
tf->device = ATA_LBA;
tf->command = WIN_SET_MAX_EXT;
tf->hob_lbal = (addr_req >>= 8) & 0xff;
tf->hob_lbam = (addr_req >>= 8) & 0xff;
tf->hob_lbah = (addr_req >>= 8) & 0xff;
if (lba48) {
tf->hob_lbal = (addr_req >>= 8) & 0xff;
tf->hob_lbam = (addr_req >>= 8) & 0xff;
tf->hob_lbah = (addr_req >>= 8) & 0xff;
tf->command = WIN_SET_MAX_EXT;
} else {
tf->device = (addr_req >>= 8) & 0x0f;
tf->command = WIN_SET_MAX;
}
tf->device |= ATA_LBA;
args.command_type = IDE_DRIVE_TASK_NO_DATA;
args.handler = &task_no_data_intr;
/* submit command request */
Expand All @@ -414,7 +375,11 @@ static unsigned long long idedisk_set_max_address_ext(ide_drive_t *drive, unsign
if ((tf->status & 0x01) == 0) {
u32 high, low;

high = (tf->hob_lbah << 16) | (tf->hob_lbam << 8) | tf->hob_lbal;
if (lba48)
high = (tf->hob_lbah << 16) | (tf->hob_lbam << 8) |
tf->hob_lbal;
else
high = tf->device & 0xf;
low = (tf->lbah << 16) | (tf->lbam << 8) | tf->lbal;
addr_set = ((__u64)high << 24) | low;
addr_set++;
Expand Down Expand Up @@ -464,10 +429,8 @@ static void idedisk_check_hpa(ide_drive_t *drive)
int lba48 = idedisk_supports_lba48(drive->id);

capacity = drive->capacity64;
if (lba48)
set_max = idedisk_read_native_max_address_ext(drive);
else
set_max = idedisk_read_native_max_address(drive);

set_max = idedisk_read_native_max_address(drive, lba48);

if (ide_in_drive_list(drive->id, hpa_list)) {
/*
Expand All @@ -488,10 +451,8 @@ static void idedisk_check_hpa(ide_drive_t *drive)
capacity, sectors_to_MB(capacity),
set_max, sectors_to_MB(set_max));

if (lba48)
set_max = idedisk_set_max_address_ext(drive, set_max);
else
set_max = idedisk_set_max_address(drive, set_max);
set_max = idedisk_set_max_address(drive, set_max, lba48);

if (set_max) {
drive->capacity64 = set_max;
printk(KERN_INFO "%s: Host Protected Area disabled.\n",
Expand Down

0 comments on commit 27e5e91

Please sign in to comment.