int atapi;
};
-static grub_err_t
+static grub_err_t
grub_ahci_readwrite_real (struct grub_ahci_device *dev,
struct grub_disk_ata_pass_through_parms *parms,
int spinup, int reset);
grub_dprintf ("ahci", "port: %d, err: %x\n", adevs[i]->port,
adevs[i]->hba->ports[adevs[i]->port].sata_error);
- adevs[i]->rfis = grub_memalign_dma32 (4096,
+ adevs[i]->rfis = grub_memalign_dma32 (4096,
sizeof (struct grub_ahci_received_fis));
grub_memset ((char *) grub_dma_get_virt (adevs[i]->rfis), 0,
sizeof (struct grub_ahci_received_fis));
adevs[i]->hba->ports[adevs[i]->port].sata_error);
grub_dprintf ("ahci", "port %d, offset: %x, tfd:%x, CMD: %x\n", adevs[i]->port,
- (int) ((char *) &adevs[i]->hba->ports[adevs[i]->port].task_file_data -
+ (int) ((char *) &adevs[i]->hba->ports[adevs[i]->port].task_file_data -
(char *) adevs[i]->hba),
adevs[i]->hba->ports[adevs[i]->port].task_file_data,
adevs[i]->hba->ports[adevs[i]->port].command);
if (adevs[i])
{
grub_dprintf ("ahci", "port %d, offset: %x, tfd:%x, CMD: %x\n", adevs[i]->port,
- (int) ((char *) &adevs[i]->hba->ports[adevs[i]->port].task_file_data -
+ (int) ((char *) &adevs[i]->hba->ports[adevs[i]->port].task_file_data -
(char *) adevs[i]->hba),
adevs[i]->hba->ports[adevs[i]->port].task_file_data,
adevs[i]->hba->ports[adevs[i]->port].command);
return GRUB_ERR_NONE;
}
-static int
+static int
reinit_port (struct grub_ahci_device *dev)
{
struct grub_pci_dma_chunk *command_list;
dev->hba->ports[dev->port].fbs = 2;
- dev->rfis = grub_memalign_dma32 (4096,
+ dev->rfis = grub_memalign_dma32 (4096,
sizeof (struct grub_ahci_received_fis));
grub_memset ((char *) grub_dma_get_virt (dev->rfis), 0,
sizeof (struct grub_ahci_received_fis));
13 /* Sectors 48 */,
8 /* LBA48 low */,
9 /* LBA48 mid */,
- 10 /* LBA48 high */ };
+ 10 /* LBA48 high */ };
static grub_err_t
grub_ahci_reset_port (struct grub_ahci_device *dev, int force)
{
grub_uint64_t endtime;
-
+
dev->hba->ports[dev->port].sata_error = dev->hba->ports[dev->port].sata_error;
if (force || (dev->hba->ports[dev->port].command_issue & 1)
return GRUB_ERR_NONE;
}
-static grub_err_t
+static grub_err_t
grub_ahci_readwrite_real (struct grub_ahci_device *dev,
struct grub_disk_ata_pass_through_parms *parms,
int spinup, int reset)
if (!reset)
grub_ahci_reset_port (dev, 0);
-
+
grub_dprintf ("ahci", "AHCI tfd = %x\n",
dev->hba->ports[dev->port].task_file_data);
dev->hba->ports[dev->port].task_file_data = 0;
dev->command_table[0].cfis[0] = GRUB_AHCI_FIS_REG_H2D;
dev->command_table[0].cfis[1] = 0x80;
for (i = 0; i < sizeof (parms->taskfile.raw); i++)
- dev->command_table[0].cfis[register_map[i]] = parms->taskfile.raw[i];
+ dev->command_table[0].cfis[register_map[i]] = parms->taskfile.raw[i];
grub_dprintf ("ahci", "cfis: %02x %02x %02x %02x %02x %02x %02x %02x\n",
dev->command_table[0].cfis[0], dev->command_table[0].cfis[1],
return err;
}
-static grub_err_t
+static grub_err_t
grub_ahci_readwrite (grub_ata_t disk,
struct grub_disk_ata_pass_through_parms *parms,
int spinup)
"sector %" PRIxGRUB_UINT64_T " cannot be "
"addressed using CHS addressing",
sector);
-
+
parms->taskfile.disk = 0xE0 | head;
parms->taskfile.sectnum = sect;
parms->taskfile.cyllsb = cylinder & 0xFF;
parms.write = rw;
if (ata->dma)
parms.dma = 1;
-
+
err = ata->dev->readwrite (ata, &parms, 0);
if (err)
return err;
grub_ata_real_close (ata);
return 0;
}
- grub_snprintf (devname, sizeof (devname),
+ grub_snprintf (devname, sizeof (devname),
"%s%d", grub_scsi_names[id], bus);
ret = ctx->hook (devname, ctx->hook_data);
grub_ata_real_close (ata);
{
struct grub_ata_iterate_ctx ctx = { hook, hook_data };
grub_ata_dev_t p;
-
+
for (p = grub_ata_dev_list; p; p = p->next)
if (p->iterate && p->iterate (grub_ata_iterate_iter, &ctx, pull))
return 1;
parms.size = size;
parms.buffer = buf;
-
+
err = dev->dev->readwrite (dev, &parms, 0);
if (err)
return err;
ata = grub_ata_real_open (id, bus);
if (!ata)
return grub_errno;
-
+
if (! ata->atapi)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no such ATAPI device");
{
struct grub_atapi_iterate_ctx ctx = { hook, hook_data };
grub_ata_dev_t p;
-
+
for (p = grub_ata_dev_list; p; p = p->next)
if (p->iterate && p->iterate (grub_atapi_iterate_iter, &ctx, pull))
return 1;
dev->cipher->cipher->blocksize);
if (err)
return err;
-
+
for (j = 0; j < (1U << log_sector_size);
j += dev->cipher->cipher->blocksize)
{
grub_crypto_xor (data + i + j, data + i + j, iv,
dev->cipher->cipher->blocksize);
if (do_encrypt)
- err = grub_crypto_ecb_encrypt (dev->cipher, data + i + j,
+ err = grub_crypto_ecb_encrypt (dev->cipher, data + i + j,
data + i + j,
dev->cipher->cipher->blocksize);
else
- err = grub_crypto_ecb_decrypt (dev->cipher, data + i + j,
+ err = grub_crypto_ecb_decrypt (dev->cipher, data + i + j,
data + i + j,
dev->cipher->cipher->blocksize);
if (err)
lrw_xor (&sec, dev, data + i);
if (do_encrypt)
- err = grub_crypto_ecb_encrypt (dev->cipher, data + i,
+ err = grub_crypto_ecb_encrypt (dev->cipher, data + i,
data + i,
(1U << log_sector_size));
else
- err = grub_crypto_ecb_decrypt (dev->cipher, data + i,
+ err = grub_crypto_ecb_decrypt (dev->cipher, data + i,
data + i,
(1U << log_sector_size));
if (err)
real_keysize /= 2;
if (dev->mode == GRUB_CRYPTODISK_MODE_LRW)
real_keysize -= dev->cipher->cipher->blocksize;
-
+
/* Set the PBKDF2 output as the cipher key. */
err = grub_crypto_cipher_set_key (dev->cipher, key, real_keysize);
if (err)
if (dev)
{
- grub_disk_close (source);
+ grub_disk_close (source);
return GRUB_ERR_NONE;
}
switch (i->mode)
{
case GRUB_CRYPTODISK_MODE_ECB:
- ptr = grub_stpcpy (ptr, "-ecb");
+ ptr = grub_stpcpy (ptr, "-ecb");
break;
case GRUB_CRYPTODISK_MODE_CBC:
ptr = grub_stpcpy (ptr, "-cbc");
switch (i->mode_iv)
{
case GRUB_CRYPTODISK_MODE_IV_NULL:
- ptr = grub_stpcpy (ptr, "-null");
+ ptr = grub_stpcpy (ptr, "-null");
break;
case GRUB_CRYPTODISK_MODE_IV_PLAIN:
- ptr = grub_stpcpy (ptr, "-plain");
+ ptr = grub_stpcpy (ptr, "-plain");
break;
case GRUB_CRYPTODISK_MODE_IV_PLAIN64:
- ptr = grub_stpcpy (ptr, "-plain64");
+ ptr = grub_stpcpy (ptr, "-plain64");
break;
case GRUB_CRYPTODISK_MODE_IV_BENBI:
- ptr = grub_stpcpy (ptr, "-benbi");
+ ptr = grub_stpcpy (ptr, "-benbi");
break;
case GRUB_CRYPTODISK_MODE_IV_ESSIV:
- ptr = grub_stpcpy (ptr, "-essiv:");
+ ptr = grub_stpcpy (ptr, "-essiv:");
ptr = grub_stpcpy (ptr, i->essiv_hash->name);
break;
case GRUB_CRYPTODISK_MODE_IV_BYTECOUNT64:
#endif
disk->partition = p;
-
+
for (arr = array_list; arr != NULL; arr = arr->next)
{
struct grub_diskfilter_pv *m;
for (diskfilter = grub_diskfilter_list; diskfilter; diskfilter = diskfilter->next)
{
#ifdef GRUB_UTIL
- grub_util_info ("Scanning for %s devices on disk %s",
+ grub_util_info ("Scanning for %s devices on disk %s",
diskfilter->name, name);
#endif
id.uuid = 0;
grub_disk_addr_t read_sector, far_ofs;
grub_uint64_t disknr, b, near, far, ofs;
unsigned int i, j;
-
+
read_sector = grub_divmod64 (sector, seg->stripe_size, &b);
far = ofs = near = 1;
far_ofs = 0;
else
far_ofs = grub_divmod64 (seg->raid_member_size,
far * seg->stripe_size, 0);
-
+
far_ofs *= seg->stripe_size;
}
- read_sector = grub_divmod64 (read_sector * near,
+ read_sector = grub_divmod64 (read_sector * near,
seg->node_count,
&disknr);
ofs *= seg->stripe_size;
read_sector *= ofs;
-
+
while (1)
{
grub_size_t read_size;
size -= read_size;
if (! size)
return GRUB_ERR_NONE;
-
+
b = 0;
disknr += (near - i);
while (disknr >= seg->node_count)
{
grub_size_t read_size;
int next_level;
-
+
read_size = seg->stripe_size - b;
if (read_size > size)
read_size = size;
disknr = 0;
}
}
- }
+ }
return GRUB_ERR_NONE;
default:
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
grub_uint64_t to_read;
extent = grub_divmod64 (sector, vg->extent_size, NULL);
-
+
/* Find the right segment. */
{
unsigned int i;
for (pv = array->pvs; pv; pv = pv->next)
if (id->uuidlen == pv->id.uuidlen
- && id->uuidlen
- ? (grub_memcmp (pv->id.uuid, id->uuid, id->uuidlen) == 0)
+ && id->uuidlen
+ ? (grub_memcmp (pv->id.uuid, id->uuid, id->uuidlen) == 0)
: (pv->id.id == id->id))
{
struct grub_diskfilter_lv *lv;
{
grub_efi_acpi_device_path_t *acpi
= (grub_efi_acpi_device_path_t *) dp;
- /* Floppy EISA ID. */
+ /* Floppy EISA ID. */
if (acpi->hid == 0x60441d0 || acpi->hid == 0x70041d0
|| acpi->hid == 0x70141d1)
is_floppy = 1;
== GRUB_EFI_MEDIA_DEVICE_PATH_TYPE)
&& (GRUB_EFI_DEVICE_PATH_SUBTYPE (c->last_device_path)
== GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE)
- && (grub_partition_get_start (disk->partition)
+ && (grub_partition_get_start (disk->partition)
== (hd->partition_start << (disk->log_sector_size
- GRUB_DISK_SECTOR_BITS)))
&& (grub_partition_get_len (disk->partition)
return gcry_err;
return grub_cryptodisk_setkey (dev, (grub_uint8_t *) key,
- dev->rekey_derived_size);
+ dev->rekey_derived_size);
}
static inline gcry_err_code_t
unsigned log_secsize;
grub_uint8_t hdr[512];
struct grub_geli_phdr *header;
- char *uuid;
+ char *uuid;
gcry_err_code_t err;
fd = grub_util_fd_open (dev, GRUB_UTIL_FD_O_RDONLY);
grub_util_error ("%s", _("couldn't read ELI metadata"));
grub_util_fd_close (fd);
-
+
COMPILE_TIME_ASSERT (sizeof (header) <= 512);
header = (void *) &hdr;
{
grub_dprintf ("geli", "not a boot volume\n");
return NULL;
- }
+ }
gcry_err = make_uuid (&header, uuid);
if (gcry_err)
if (grub_le_to_cpu16 (header.alg) == 0x16)
real_keysize *= 2;
gcry_err = grub_cryptodisk_setkey (dev, candidate_key.cipher_key,
- real_keysize);
+ real_keysize);
if (gcry_err)
return grub_crypto_gcry_error (gcry_err);
}
* non-zero, otherwise zero.
*/
-static int
+static int
grub_biosdisk_rw_int13_extensions (int ah, int drive, void *dap)
{
struct grub_bios_int_registers regs;
* NSEC sectors from COFF/HOFF/SOFF into SEGMENT. If an error occurs,
* return non-zero, otherwise zero.
*/
-static int
+static int
grub_biosdisk_rw_standard (int ah, int drive, int coff, int hoff,
int soff, int nsec, int segment)
{
/* set bits 0-5 of %cl to sector */
regs.ecx |= soff & 0x3f;
- /* set %dh to head and %dl to drive */
+ /* set %dh to head and %dl to drive */
regs.edx = (drive & 0xff) | ((hoff << 8) & 0xff00);
/* set %ah to AH */
regs.eax = (ah << 8) & 0xff00;
regs.ebx = 0x55aa;
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
grub_bios_interrupt (0x13, ®s);
-
+
if (regs.flags & GRUB_CPU_INT_FLAGS_CARRY)
return 0;
* Return the geometry of DRIVE in CYLINDERS, HEADS and SECTORS. If an
* error occurs, then return non-zero, otherwise zero.
*/
-static int
+static int
grub_biosdisk_get_diskinfo_standard (int drive,
unsigned long *cylinders,
unsigned long *heads,
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
grub_bios_interrupt (0x13, ®s);
- /* Check if unsuccessful. Ignore return value if carry isn't set to
+ /* Check if unsuccessful. Ignore return value if carry isn't set to
workaround some buggy BIOSes. */
if ((regs.flags & GRUB_CPU_INT_FLAGS_CARRY) && ((regs.eax & 0xff00) != 0))
return (regs.eax & 0xff00) >> 8;
- /* bogus BIOSes may not return an error number */
+ /* bogus BIOSes may not return an error number */
/* 0 sectors means no disk */
if (!(regs.ecx & 0x3f))
/* XXX 0x60 is one of the unused error numbers */
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
grub_bios_interrupt (0x13, ®s);
- /* Check if unsuccessful. Ignore return value if carry isn't set to
+ /* Check if unsuccessful. Ignore return value if carry isn't set to
workaround some buggy BIOSes. */
if ((regs.flags & GRUB_CPU_INT_FLAGS_CARRY) && ((regs.eax & 0xff00) != 0))
return (regs.eax & 0xff00) >> 8;
return 0;
scan ();
-
+
for (i = 0; i < ARRAY_SIZE (ofdisk_hash); i++)
{
static struct ofdisk_hash_ent *ent;
if (hook (ent->grub_shortest, hook_data))
return 1;
}
- }
+ }
return 0;
}
grub_ieee1275_open (disk->data, &last_ihandle);
if (! last_ihandle)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device");
- last_devpath = disk->data;
+ last_devpath = disk->data;
}
pos = sector << disk->log_sector_size;
}
grub_memcpy (pv->internal_id, ptr, (grub_size_t) ptr[0] + 1);
pv->internal_id[(grub_size_t) ptr[0] + 1] = 0;
-
+
ptr += *ptr + 1;
if (ptr + *ptr + 1 >= vblk[i].dynamic
+ sizeof (vblk[i].dynamic))
return NULL;
}
-static struct grub_diskfilter_vg *
+static struct grub_diskfilter_vg *
grub_ldm_detect (grub_disk_t disk,
struct grub_diskfilter_pv_id *id,
grub_disk_addr_t *start_sector)
grub_dprintf ("luks", "PBKDF2 done\n");
- gcry_err = grub_cryptodisk_setkey (dev, digest, keysize);
+ gcry_err = grub_cryptodisk_setkey (dev, digest, keysize);
if (gcry_err)
{
grub_free (split_key);
grub_printf_ (N_("Slot %d opened\n"), i);
/* Set the master key. */
- gcry_err = grub_cryptodisk_setkey (dev, candidate_key, keysize);
+ gcry_err = grub_cryptodisk_setkey (dev, candidate_key, keysize);
if (gcry_err)
{
grub_free (split_key);
}
}
-static struct grub_diskfilter_vg *
+static struct grub_diskfilter_vg *
grub_lvm_detect (grub_disk_t disk,
struct grub_diskfilter_pv_id *id,
grub_disk_addr_t *start_sector)
lv1->segments[i].nodes[j].lv = lv2;
}
}
-
+
}
{
grub_uint32_t level;
struct grub_diskfilter_vg *array;
char *uuid;
-
+
if (size == GRUB_DISK_SIZE_UNKNOWN && minor_version == 0)
continue;
-
+
switch (minor_version)
{
case 0:
/* Spares aren't implemented. */
return NULL;
- if (grub_disk_read (disk, sector,
+ if (grub_disk_read (disk, sector,
(char *) (sb.dev_roles + grub_le_to_cpu32 (sb.dev_number))
- (char *) &sb,
sizeof (role), &role))
grub_le_to_cpu32 (sb.raid_disks),
sb.set_name,
(sb.size)
- ? grub_le_to_cpu64 (sb.size)
+ ? grub_le_to_cpu64 (sb.size)
: grub_le_to_cpu64 (sb.data_size),
grub_le_to_cpu32 (sb.chunksize),
grub_le_to_cpu32 (sb.layout),
static void
grub_pata_pio_read (struct grub_pata_device *dev, char *buf, grub_size_t size)
-{
+{
unsigned int i;
/* Read in the data, word by word. */
struct grub_scsi_test_unit_ready tur;
grub_err_t err;
grub_err_t err_sense;
-
+
tur.opcode = grub_scsi_cmd_test_unit_ready;
tur.lun = scsi->lun << GRUB_SCSI_LUN_SHIFT;
tur.reserved1 = 0;
if (err_sense != GRUB_ERR_NONE)
grub_errno = err;
/* err_sense is ignored for now and Request Sense Data also... */
-
+
if (err)
return err;
rc.PMI = 0;
rc.control = 0;
rc.pad = 0;
-
+
err = scsi->dev->read (scsi, sizeof (rc), (char *) &rc,
sizeof (rcd), (char *) &rcd);
rc.alloc_len = grub_cpu_to_be32_compile_time (sizeof (rcd));
rc.PMI = 0;
rc.control = 0;
-
+
err = scsi->dev->read (scsi, sizeof (rc), (char *) &rc,
sizeof (rcd), (char *) &rcd);
{ 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff }
};
-
+
return grub_usbms_cbi_cmd (dev, interface, (grub_uint8_t *)&cbicb);
}
/* Experimental support of RBC, MMC-2, UFI, SFF-8070i devices */
&& interf->subclass != GRUB_USBMS_SUBCLASS_RBC
&& interf->subclass != GRUB_USBMS_SUBCLASS_MMC2
- && interf->subclass != GRUB_USBMS_SUBCLASS_UFI
+ && interf->subclass != GRUB_USBMS_SUBCLASS_UFI
&& interf->subclass != GRUB_USBMS_SUBCLASS_SFF8070 )
|| (interf->protocol != GRUB_USBMS_PROTOCOL_BULK
&& interf->protocol != GRUB_USBMS_PROTOCOL_CBI
if (grub_usbms_devices[curnum]->protocol == GRUB_USBMS_PROTOCOL_BULK)
{ /* Only Bulk only devices support Get Max LUN command */
err = grub_usb_control_msg (usbdev, 0xA1, 254, 0, interfno, 1, (char *) &luns);
-
+
if (err)
{
/* In case of a stall, clear the stall. */
else
/* luns = 0 means one LUN with ID 0 present ! */
/* We get from device not number of LUNs but highest
- * LUN number. LUNs are numbered from 0,
+ * LUN number. LUNs are numbered from 0,
* i.e. number of LUNs is luns+1 ! */
grub_usbms_devices[curnum]->luns = luns + 1;
}
/* XXX: Does CBI devices support multiple LUNs ?
* I.e., should we detect number of device's LUNs ? (How?) */
grub_usbms_devices[curnum]->luns = 1;
-
+
grub_dprintf ("usbms", "alive\n");
usbdev->config[configno].interf[interfno].detach_hook = grub_usbms_detach;
grub_usb_err_t err = GRUB_USB_ERR_NONE;
grub_usb_err_t errCSW = GRUB_USB_ERR_NONE;
int retrycnt = 3 + 1;
-
+
tag++;
retry:
cbw.lun = scsi->lun; /* In USB MS CBW are LUN bits on another place than in SCSI CDB, both should be set correctly. */
cbw.length = cmdsize;
grub_memcpy (cbw.cbwcb, cmd, cmdsize);
-
+
/* Debug print of CBW content. */
grub_dprintf ("usb", "CBW: sign=0x%08x tag=0x%08x len=0x%08x\n",
cbw.signature, cbw.tag, cbw.transfer_length);
if (size && (read_write == 0))
{
err = grub_usb_bulk_read (dev->dev, dev->in, size, buf);
- grub_dprintf ("usb", "read: %d %d\n", err, GRUB_USB_ERR_STALL);
+ grub_dprintf ("usb", "read: %d %d\n", err, GRUB_USB_ERR_STALL);
if (err)
{
if (err == GRUB_USB_ERR_STALL)
grub_dprintf ("usb", "CSW: sign=0x%08x tag=0x%08x resid=0x%08x\n",
status.signature, status.tag, status.residue);
grub_dprintf ("usb", "CSW: status=0x%02x\n", status.status);
-
+
/* If phase error or not valid signature, do bulk-only reset device. */
if ((status.status == 2) ||
(status.signature != grub_cpu_to_le32_compile_time(0x53425355)))
grub_usb_err_t err = GRUB_USB_ERR_NONE;
grub_uint8_t cbicb[GRUB_USBMS_CBI_CMD_SIZE];
grub_uint16_t status;
-
+
retry:
retrycnt--;
if (retrycnt == 0)
cmdsize >= GRUB_USBMS_CBI_CMD_SIZE
? GRUB_USBMS_CBI_CMD_SIZE
: cmdsize);
-
+
/* Debug print of CBIcb content. */
grub_dprintf ("usb", "cbicb:\n %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
cbicb[ 0], cbicb[ 1], cbicb[ 2], cbicb[ 3],
if (size && (read_write == 0))
{
err = grub_usb_bulk_read (dev->dev, dev->in, size, buf);
- grub_dprintf ("usb", "read: %d\n", err);
+ grub_dprintf ("usb", "read: %d\n", err);
if (err)
{
if (err == GRUB_USB_ERR_STALL)
if (err)
return grub_error (GRUB_ERR_IO, "USB error %d", err);
-
+
return GRUB_ERR_NONE;
}