Parcourir la source

[int13] Add support for INT 13,4b

This allows the ELTORITO.SYS driver for MS-DOS to access our emulated
CD-ROM drives.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown il y a 13 ans
Parent
révision
d75d6f65aa
1 fichiers modifiés avec 46 ajouts et 4 suppressions
  1. 46
    4
      src/arch/i386/interface/pcbios/int13.c

+ 46
- 4
src/arch/i386/interface/pcbios/int13.c Voir le fichier

@@ -124,6 +124,8 @@ struct int13_drive {
124 124
 	 */
125 125
 	unsigned int sectors_per_track;
126 126
 
127
+	/** Drive is a CD-ROM */
128
+	int is_cdrom;
127 129
 	/** Address of El Torito boot catalog (if any) */
128 130
 	unsigned int boot_catalog;
129 131
 
@@ -468,6 +470,7 @@ static int int13_parse_iso9660 ( struct int13_drive *int13, void *scratch ) {
468 470
 		return 0;
469 471
 	DBGC ( int13, "INT13 drive %02x contains an ISO9660 filesystem; "
470 472
 	       "treating as CD-ROM\n", int13->drive );
473
+	int13->is_cdrom = 1;
471 474
 
472 475
 	/* Read boot record volume descriptor */
473 476
 	if ( ( rc = int13_rw ( int13,
@@ -1090,6 +1093,41 @@ static int int13_get_extended_parameters ( struct int13_drive *int13,
1090 1093
 	return 0;
1091 1094
 }
1092 1095
 
1096
+/**
1097
+ * INT 13, 4b - Get status or terminate CD-ROM emulation
1098
+ *
1099
+ * @v int13		Emulated drive
1100
+ * @v ds:si		Specification packet
1101
+ * @ret status		Status code
1102
+ */
1103
+static int int13_cdrom_status_terminate ( struct int13_drive *int13,
1104
+					  struct i386_all_regs *ix86 ) {
1105
+	struct int13_cdrom_specification specification;
1106
+
1107
+	DBGC2 ( int13, "Get CD-ROM emulation status to %04x:%04x%s\n",
1108
+		ix86->segs.ds, ix86->regs.si,
1109
+		( ix86->regs.al ? "" : " and terminate" ) );
1110
+
1111
+	/* Fail if we are not a CD-ROM */
1112
+	if ( ! int13->is_cdrom ) {
1113
+		DBGC ( int13, "INT13 drive %02x is not a CD-ROM\n",
1114
+		       int13->drive );
1115
+		return -INT13_STATUS_INVALID;
1116
+	}
1117
+
1118
+	/* Build specification packet */
1119
+	memset ( &specification, 0, sizeof ( specification ) );
1120
+	specification.size = sizeof ( specification );
1121
+	specification.drive = int13->drive;
1122
+
1123
+	/* Return specification packet */
1124
+	copy_to_real ( ix86->segs.ds, ix86->regs.si, &specification,
1125
+		       sizeof ( specification ) );
1126
+
1127
+	return 0;
1128
+}
1129
+
1130
+
1093 1131
 /**
1094 1132
  * INT 13, 4d - Read CD-ROM boot catalog
1095 1133
  *
@@ -1102,6 +1140,11 @@ static int int13_cdrom_read_boot_catalog ( struct int13_drive *int13,
1102 1140
 	struct int13_cdrom_boot_catalog_command command;
1103 1141
 	int rc;
1104 1142
 
1143
+	/* Read parameters from command packet */
1144
+	copy_from_real ( &command, ix86->segs.ds, ix86->regs.si,
1145
+			 sizeof ( command ) );
1146
+	DBGC2 ( int13, "Read CD-ROM boot catalog to %08x\n", command.buffer );
1147
+
1105 1148
 	/* Fail if we have no boot catalog */
1106 1149
 	if ( ! int13->boot_catalog ) {
1107 1150
 		DBGC ( int13, "INT13 drive %02x has no boot catalog\n",
@@ -1109,10 +1152,6 @@ static int int13_cdrom_read_boot_catalog ( struct int13_drive *int13,
1109 1152
 		return -INT13_STATUS_INVALID;
1110 1153
 	}
1111 1154
 
1112
-	/* Read parameters from command packet */
1113
-	copy_from_real ( &command, ix86->segs.ds, ix86->regs.si,
1114
-			 sizeof ( command ) );
1115
-
1116 1155
 	/* Read from boot catalog */
1117 1156
 	if ( ( rc = int13_rw ( int13, ( int13->boot_catalog + command.start ),
1118 1157
 			       command.count, phys_to_user ( command.buffer ),
@@ -1192,6 +1231,9 @@ static __asmcall void int13 ( struct i386_all_regs *ix86 ) {
1192 1231
 		case INT13_GET_EXTENDED_PARAMETERS:
1193 1232
 			status = int13_get_extended_parameters ( int13, ix86 );
1194 1233
 			break;
1234
+		case INT13_CDROM_STATUS_TERMINATE:
1235
+			status = int13_cdrom_status_terminate ( int13, ix86 );
1236
+			break;
1195 1237
 		case INT13_CDROM_READ_BOOT_CATALOG:
1196 1238
 			status = int13_cdrom_read_boot_catalog ( int13, ix86 );
1197 1239
 			break;

Chargement…
Annuler
Enregistrer