* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#ifndef _M_ARM
#include <freeldr.h>
-#include <disk.h>
-#include <arch.h>
-#include <rtl.h>
-#include <ui.h>
#include <debug.h>
-
#undef UNIMPLEMENTED
#define UNIMPLEMENTED BugCheck((DPRINT_WARNING, "Unimplemented\n"));
-static BOOL bReportError = TRUE;
+static BOOLEAN bReportError = TRUE;
/////////////////////////////////////////////////////////////////////////////////////////////
// FUNCTIONS
/////////////////////////////////////////////////////////////////////////////////////////////
-VOID DiskReportError (BOOL bError)
+VOID DiskReportError (BOOLEAN bError)
{
bReportError = bError;
}
-VOID DiskError(PCHAR ErrorString, ULONG ErrorCode)
+VOID DiskError(PCSTR ErrorString, ULONG ErrorCode)
{
CHAR ErrorCodeString[200];
if (bReportError == FALSE)
return;
- sprintf(ErrorCodeString, "%s\n\nError Code: 0x%x\nError: %s", ErrorString, ErrorCode, DiskGetErrorCodeString(ErrorCode));
+ sprintf(ErrorCodeString, "%s\n\nError Code: 0x%lx\nError: %s", ErrorString, ErrorCode, DiskGetErrorCodeString(ErrorCode));
- DbgPrint((DPRINT_DISK, "%s\n", ErrorCodeString));
+ DPRINTM(DPRINT_DISK, "%s\n", ErrorCodeString);
UiMessageBox(ErrorCodeString);
}
-PCHAR DiskGetErrorCodeString(ULONG ErrorCode)
+PCSTR DiskGetErrorCodeString(ULONG ErrorCode)
{
switch (ErrorCode)
{
}
// This function is in arch/i386/i386disk.c
-//BOOL DiskReadLogicalSectors(ULONG DriveNumber, U64 SectorNumber, ULONG SectorCount, PVOID Buffer)
+//BOOLEAN DiskReadLogicalSectors(ULONG DriveNumber, U64 SectorNumber, ULONG SectorCount, PVOID Buffer)
-BOOL DiskIsDriveRemovable(ULONG DriveNumber)
+BOOLEAN DiskIsDriveRemovable(ULONG DriveNumber)
{
// Hard disks use drive numbers >= 0x80
// So if the drive number indicates a hard disk
// then return FALSE
- if (DriveNumber >= 0x80)
+ // 0x49 is our magic ramdisk drive, so return FALSE for that too
+ if ((DriveNumber >= 0x80) || (DriveNumber == 0x49))
{
return FALSE;
}
return TRUE;
}
+BOOLEAN
+DiskGetBootPath(char *BootPath, unsigned Size)
+{
+ static char Path[] = "multi(0)disk(0)";
+ char Device[4];
+
+ _itoa(BootDrive, Device, 10);
+ if (Size <= sizeof(Path) + 6 + strlen(Device))
+ {
+ return FALSE;
+ }
+ strcpy(BootPath, Path);
+ strcat(BootPath, BootDrive < 0x80 ? "fdisk" : "cdrom");
+ strcat(strcat(strcat(BootPath, "("), Device), ")");
+
+ if (strcmp(BootPath, "multi(0)disk(0)cdrom(128)") == 0)
+ strcpy(BootPath, "multi(0)disk(0)rdisk(0)partition(1)");
+ return TRUE;
+}
+
+BOOLEAN
+DiskNormalizeSystemPath(char *SystemPath, unsigned Size)
+{
+ CHAR BootPath[256];
+ ULONG PartitionNumber;
+ ULONG DriveNumber;
+ PARTITION_TABLE_ENTRY PartEntry;
+ char *p;
+
+ if (!DissectArcPath(SystemPath, BootPath, &DriveNumber, &PartitionNumber))
+ {
+ return FALSE;
+ }
+
+ if (0 != PartitionNumber)
+ {
+ return TRUE;
+ }
+
+ if (! DiskGetActivePartitionEntry(DriveNumber,
+ &PartEntry,
+ &PartitionNumber) ||
+ PartitionNumber < 1 || 9 < PartitionNumber)
+ {
+ return FALSE;
+ }
+
+ p = SystemPath;
+ while ('\0' != *p && 0 != _strnicmp(p, "partition(", 10)) {
+ p++;
+ }
+ p = strchr(p, ')');
+ if (NULL == p || '0' != *(p - 1)) {
+ return FALSE;
+ }
+ *(p - 1) = '0' + PartitionNumber;
+
+ return TRUE;
+}
+
+
// This function is in arch/i386/i386disk.c
//VOID DiskStopFloppyMotor(VOID)
// This function is in arch/i386/i386disk.c
//ULONG DiskGetCacheableBlockCount(ULONG DriveNumber)
+
+#endif