Kaynağa Gözat

[block] Provide sandev_read() and sandev_write() as global symbols

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 7 yıl önce
ebeveyn
işleme
dd976cb50d

+ 23
- 27
src/arch/x86/interface/pcbios/int13.c Dosyayı Görüntüle

@@ -181,8 +181,8 @@ static int int13_parse_eltorito ( struct san_device *sandev, void *scratch ) {
181 181
 	int rc;
182 182
 
183 183
 	/* Read boot record volume descriptor */
184
-	if ( ( rc = sandev_rw ( sandev, ELTORITO_LBA, 1,
185
-				virt_to_user ( boot ), block_read ) ) != 0 ) {
184
+	if ( ( rc = sandev_read ( sandev, ELTORITO_LBA, 1,
185
+				  virt_to_user ( boot ) ) ) != 0 ) {
186 186
 		DBGC ( sandev, "INT13 drive %02x could not read El Torito boot "
187 187
 		       "record volume descriptor: %s\n",
188 188
 		       sandev->drive, strerror ( rc ) );
@@ -227,8 +227,7 @@ static int int13_guess_geometry_hdd ( struct san_device *sandev, void *scratch,
227 227
 	int rc;
228 228
 
229 229
 	/* Read partition table */
230
-	if ( ( rc = sandev_rw ( sandev, 0, 1, virt_to_user ( mbr ),
231
-				block_read ) ) != 0 ) {
230
+	if ( ( rc = sandev_read ( sandev, 0, 1, virt_to_user ( mbr ) ) ) != 0 ) {
232 231
 		DBGC ( sandev, "INT13 drive %02x could not read "
233 232
 		       "partition table to guess geometry: %s\n",
234 233
 		       sandev->drive, strerror ( rc ) );
@@ -506,18 +505,16 @@ static int int13_get_last_status ( struct san_device *sandev,
506 505
  * @v cl (bits 5:0)	Sector number
507 506
  * @v dh		Head number
508 507
  * @v es:bx		Data buffer
509
- * @v block_rw		Block read/write method
508
+ * @v sandev_rw		SAN device read/write method
510 509
  * @ret status		Status code
511 510
  * @ret al		Number of sectors read or written
512 511
  */
513 512
 static int int13_rw_sectors ( struct san_device *sandev,
514 513
 			      struct i386_all_regs *ix86,
515
-			      int ( * block_rw ) ( struct interface *control,
516
-						   struct interface *data,
517
-						   uint64_t lba,
518
-						   unsigned int count,
519
-						   userptr_t buffer,
520
-						   size_t len ) ) {
514
+			      int ( * sandev_rw ) ( struct san_device *sandev,
515
+						    uint64_t lba,
516
+						    unsigned int count,
517
+						    userptr_t buffer ) ) {
521 518
 	struct int13_data *int13 = sandev->priv;
522 519
 	unsigned int cylinder, head, sector;
523 520
 	unsigned long lba;
@@ -555,7 +552,7 @@ static int int13_rw_sectors ( struct san_device *sandev,
555 552
 		count );
556 553
 
557 554
 	/* Read from / write to block device */
558
-	if ( ( rc = sandev_rw ( sandev, lba, count, buffer, block_rw ) ) != 0 ){
555
+	if ( ( rc = sandev_rw ( sandev, lba, count, buffer ) ) != 0 ){
559 556
 		DBGC ( sandev, "INT13 drive %02x I/O failed: %s\n",
560 557
 		       sandev->drive, strerror ( rc ) );
561 558
 		return -INT13_STATUS_READ_ERROR;
@@ -581,7 +578,7 @@ static int int13_read_sectors ( struct san_device *sandev,
581 578
 				struct i386_all_regs *ix86 ) {
582 579
 
583 580
 	DBGC2 ( sandev, "Read: " );
584
-	return int13_rw_sectors ( sandev, ix86, block_read );
581
+	return int13_rw_sectors ( sandev, ix86, sandev_read );
585 582
 }
586 583
 
587 584
 /**
@@ -601,7 +598,7 @@ static int int13_write_sectors ( struct san_device *sandev,
601 598
 				 struct i386_all_regs *ix86 ) {
602 599
 
603 600
 	DBGC2 ( sandev, "Write: " );
604
-	return int13_rw_sectors ( sandev, ix86, block_write );
601
+	return int13_rw_sectors ( sandev, ix86, sandev_write );
605 602
 }
606 603
 
607 604
 /**
@@ -701,17 +698,15 @@ static int int13_extension_check ( struct san_device *sandev __unused,
701 698
  *
702 699
  * @v sandev		SAN device
703 700
  * @v ds:si		Disk address packet
704
- * @v block_rw		Block read/write method
701
+ * @v sandev_rw		SAN device read/write method
705 702
  * @ret status		Status code
706 703
  */
707 704
 static int int13_extended_rw ( struct san_device *sandev,
708 705
 			       struct i386_all_regs *ix86,
709
-			       int ( * block_rw ) ( struct interface *control,
710
-						    struct interface *data,
711
-						    uint64_t lba,
712
-						    unsigned int count,
713
-						    userptr_t buffer,
714
-						    size_t len ) ) {
706
+			       int ( * sandev_rw ) ( struct san_device *sandev,
707
+						     uint64_t lba,
708
+						     unsigned int count,
709
+						     userptr_t buffer ) ) {
715 710
 	struct int13_disk_address addr;
716 711
 	uint8_t bufsize;
717 712
 	uint64_t lba;
@@ -762,7 +757,7 @@ static int int13_extended_rw ( struct san_device *sandev,
762 757
 	DBGC2 ( sandev, " (count %ld)\n", count );
763 758
 
764 759
 	/* Read from / write to block device */
765
-	if ( ( rc = sandev_rw ( sandev, lba, count, buffer, block_rw ) ) != 0 ){
760
+	if ( ( rc = sandev_rw ( sandev, lba, count, buffer ) ) != 0 ) {
766 761
 		DBGC ( sandev, "INT13 drive %02x extended I/O failed: %s\n",
767 762
 		       sandev->drive, strerror ( rc ) );
768 763
 		/* Record that no blocks were transferred successfully */
@@ -787,7 +782,7 @@ static int int13_extended_read ( struct san_device *sandev,
787 782
 				 struct i386_all_regs *ix86 ) {
788 783
 
789 784
 	DBGC2 ( sandev, "Extended read: " );
790
-	return int13_extended_rw ( sandev, ix86, block_read );
785
+	return int13_extended_rw ( sandev, ix86, sandev_read );
791 786
 }
792 787
 
793 788
 /**
@@ -801,7 +796,7 @@ static int int13_extended_write ( struct san_device *sandev,
801 796
 				  struct i386_all_regs *ix86 ) {
802 797
 
803 798
 	DBGC2 ( sandev, "Extended write: " );
804
-	return int13_extended_rw ( sandev, ix86, block_write );
799
+	return int13_extended_rw ( sandev, ix86, sandev_write );
805 800
 }
806 801
 
807 802
 /**
@@ -1038,6 +1033,7 @@ static int int13_cdrom_read_boot_catalog ( struct san_device *sandev,
1038 1033
 					   struct i386_all_regs *ix86 ) {
1039 1034
 	struct int13_data *int13 = sandev->priv;
1040 1035
 	struct int13_cdrom_boot_catalog_command command;
1036
+	unsigned int start;
1041 1037
 	int rc;
1042 1038
 
1043 1039
 	/* Read parameters from command packet */
@@ -1051,11 +1047,11 @@ static int int13_cdrom_read_boot_catalog ( struct san_device *sandev,
1051 1047
 		       sandev->drive );
1052 1048
 		return -INT13_STATUS_INVALID;
1053 1049
 	}
1050
+	start = ( int13->boot_catalog + command.start );
1054 1051
 
1055 1052
 	/* Read from boot catalog */
1056
-	if ( ( rc = sandev_rw ( sandev, ( int13->boot_catalog + command.start ),
1057
-				command.count, phys_to_user ( command.buffer ),
1058
-				block_read ) ) != 0 ) {
1053
+	if ( ( rc = sandev_read ( sandev, start, command.count,
1054
+				  phys_to_user ( command.buffer ) ) ) != 0 ) {
1059 1055
 		DBGC ( sandev, "INT13 drive %02x could not read boot catalog: "
1060 1056
 		       "%s\n", sandev->drive, strerror ( rc ) );
1061 1057
 		return -INT13_STATUS_READ_ERROR;

+ 48
- 8
src/core/sanboot.c Dosyayı Görüntüle

@@ -577,12 +577,12 @@ int sandev_reset ( struct san_device *sandev ) {
577 577
  * @v block_rw		Block read/write method
578 578
  * @ret rc		Return status code
579 579
  */
580
-int sandev_rw ( struct san_device *sandev, uint64_t lba,
581
-		unsigned int count, userptr_t buffer,
582
-		int ( * block_rw ) ( struct interface *control,
583
-				     struct interface *data,
584
-				     uint64_t lba, unsigned int count,
585
-				     userptr_t buffer, size_t len ) ) {
580
+static int sandev_rw ( struct san_device *sandev, uint64_t lba,
581
+		       unsigned int count, userptr_t buffer,
582
+		       int ( * block_rw ) ( struct interface *control,
583
+					    struct interface *data,
584
+					    uint64_t lba, unsigned int count,
585
+					    userptr_t buffer, size_t len ) ) {
586 586
 	union san_command_params params;
587 587
 	unsigned int remaining;
588 588
 	size_t frag_len;
@@ -617,6 +617,46 @@ int sandev_rw ( struct san_device *sandev, uint64_t lba,
617 617
 	return 0;
618 618
 }
619 619
 
620
+/**
621
+ * Read from SAN device
622
+ *
623
+ * @v sandev		SAN device
624
+ * @v lba		Starting logical block address
625
+ * @v count		Number of logical blocks
626
+ * @v buffer		Data buffer
627
+ * @ret rc		Return status code
628
+ */
629
+int sandev_read ( struct san_device *sandev, uint64_t lba,
630
+		  unsigned int count, userptr_t buffer ) {
631
+	int rc;
632
+
633
+	/* Read from device */
634
+	if ( ( rc = sandev_rw ( sandev, lba, count, buffer, block_read ) ) != 0 )
635
+		return rc;
636
+
637
+	return 0;
638
+}
639
+
640
+/**
641
+ * Write to SAN device
642
+ *
643
+ * @v sandev		SAN device
644
+ * @v lba		Starting logical block address
645
+ * @v count		Number of logical blocks
646
+ * @v buffer		Data buffer
647
+ * @ret rc		Return status code
648
+ */
649
+int sandev_write ( struct san_device *sandev, uint64_t lba,
650
+		   unsigned int count, userptr_t buffer ) {
651
+	int rc;
652
+
653
+	/* Write to device */
654
+	if ( ( rc = sandev_rw ( sandev, lba, count, buffer, block_write ) ) != 0 )
655
+		return rc;
656
+
657
+	return 0;
658
+}
659
+
620 660
 /**
621 661
  * Describe SAN device
622 662
  *
@@ -735,8 +775,8 @@ static int sandev_parse_iso9660 ( struct san_device *sandev ) {
735 775
 	}
736 776
 
737 777
 	/* Read primary volume descriptor */
738
-	if ( ( rc = sandev_rw ( sandev, lba, count, virt_to_user ( scratch ),
739
-				block_read ) ) != 0 ) {
778
+	if ( ( rc = sandev_read ( sandev, lba, count,
779
+				  virt_to_user ( scratch ) ) ) != 0 ) {
740 780
 		DBGC ( sandev, "SAN %#02x could not read ISO9660 primary"
741 781
 		       "volume descriptor: %s\n",
742 782
 		       sandev->drive, strerror ( rc ) );

+ 4
- 6
src/include/ipxe/sanboot.h Dosyayı Görüntüle

@@ -236,12 +236,10 @@ static inline int sandev_needs_reopen ( struct san_device *sandev ) {
236 236
 extern struct san_device * sandev_find ( unsigned int drive );
237 237
 extern int sandev_reopen ( struct san_device *sandev );
238 238
 extern int sandev_reset ( struct san_device *sandev );
239
-extern int sandev_rw ( struct san_device *sandev, uint64_t lba,
240
-		       unsigned int count, userptr_t buffer,
241
-		       int ( * block_rw ) ( struct interface *control,
242
-					    struct interface *data,
243
-					    uint64_t lba, unsigned int count,
244
-					    userptr_t buffer, size_t len ) );
239
+extern int sandev_read ( struct san_device *sandev, uint64_t lba,
240
+			 unsigned int count, userptr_t buffer );
241
+extern int sandev_write ( struct san_device *sandev, uint64_t lba,
242
+			  unsigned int count, userptr_t buffer );
245 243
 extern struct san_device * alloc_sandev ( struct uri **uris, unsigned int count,
246 244
 					  size_t priv_size );
247 245
 extern int register_sandev ( struct san_device *sandev, unsigned int drive,

+ 8
- 9
src/interface/efi/efi_block.c Dosyayı Görüntüle

@@ -102,15 +102,14 @@ struct efi_block_data {
102 102
  * @v lba		Starting LBA
103 103
  * @v data		Data buffer
104 104
  * @v len		Size of buffer
105
- * @v block_rw		Block read/write method
105
+ * @v sandev_rw		SAN device read/write method
106 106
  * @ret rc		Return status code
107 107
  */
108 108
 static int efi_block_rw ( struct san_device *sandev, uint64_t lba,
109 109
 			  void *data, size_t len,
110
-			  int ( * block_rw ) ( struct interface *control,
111
-					       struct interface *data,
112
-					       uint64_t lba, unsigned int count,
113
-					       userptr_t buffer, size_t len ) ){
110
+			  int ( * sandev_rw ) ( struct san_device *sandev,
111
+						uint64_t lba, unsigned int count,
112
+						userptr_t buffer ) ) {
114 113
 	struct efi_block_data *block = sandev->priv;
115 114
 	unsigned int count;
116 115
 	int rc;
@@ -124,8 +123,8 @@ static int efi_block_rw ( struct san_device *sandev, uint64_t lba,
124 123
 	}
125 124
 
126 125
 	/* Read from / write to block device */
127
-	if ( ( rc = sandev_rw ( sandev, lba, count, virt_to_user ( data ),
128
-				block_rw ) ) != 0 ) {
126
+	if ( ( rc = sandev_rw ( sandev, lba, count,
127
+				virt_to_user ( data ) ) ) != 0 ) {
129 128
 		DBGC ( sandev, "EFIBLK %#02x I/O failed: %s\n",
130 129
 		       sandev->drive, strerror ( rc ) );
131 130
 		return rc;
@@ -176,7 +175,7 @@ efi_block_io_read ( EFI_BLOCK_IO_PROTOCOL *block_io, UINT32 media __unused,
176 175
 	DBGC2 ( sandev, "EFIBLK %#02x read LBA %#08llx to %p+%#08zx\n",
177 176
 		sandev->drive, lba, data, ( ( size_t ) len ) );
178 177
 	efi_snp_claim();
179
-	rc = efi_block_rw ( sandev, lba, data, len, block_read );
178
+	rc = efi_block_rw ( sandev, lba, data, len, sandev_read );
180 179
 	efi_snp_release();
181 180
 	return EFIRC ( rc );
182 181
 }
@@ -202,7 +201,7 @@ efi_block_io_write ( EFI_BLOCK_IO_PROTOCOL *block_io, UINT32 media __unused,
202 201
 	DBGC2 ( sandev, "EFIBLK %#02x write LBA %#08llx from %p+%#08zx\n",
203 202
 		sandev->drive, lba, data, ( ( size_t ) len ) );
204 203
 	efi_snp_claim();
205
-	rc = efi_block_rw ( sandev, lba, data, len, block_write );
204
+	rc = efi_block_rw ( sandev, lba, data, len, sandev_write );
206 205
 	efi_snp_release();
207 206
 	return EFIRC ( rc );
208 207
 }

Loading…
İptal
Kaydet