Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygendisk.c
Go to the documentation of this file.
00001 /* 00002 * FreeLoader 00003 * Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com> 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License along 00016 * with this program; if not, write to the Free Software Foundation, Inc., 00017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00018 */ 00019 00020 #ifndef _M_ARM 00021 #include <freeldr.h> 00022 #include <debug.h> 00023 00024 DBG_DEFAULT_CHANNEL(DISK); 00025 00026 static BOOLEAN bReportError = TRUE; 00027 00029 // FUNCTIONS 00031 00032 VOID DiskReportError (BOOLEAN bError) 00033 { 00034 bReportError = bError; 00035 } 00036 00037 VOID DiskError(PCSTR ErrorString, ULONG ErrorCode) 00038 { 00039 CHAR ErrorCodeString[200]; 00040 00041 if (bReportError == FALSE) 00042 return; 00043 00044 sprintf(ErrorCodeString, "%s\n\nError Code: 0x%lx\nError: %s", ErrorString, ErrorCode, DiskGetErrorCodeString(ErrorCode)); 00045 00046 TRACE("%s\n", ErrorCodeString); 00047 00048 UiMessageBox(ErrorCodeString); 00049 } 00050 00051 PCSTR DiskGetErrorCodeString(ULONG ErrorCode) 00052 { 00053 switch (ErrorCode) 00054 { 00055 case 0x00: return "no error"; 00056 case 0x01: return "bad command passed to driver"; 00057 case 0x02: return "address mark not found or bad sector"; 00058 case 0x03: return "diskette write protect error"; 00059 case 0x04: return "sector not found"; 00060 case 0x05: return "fixed disk reset failed"; 00061 case 0x06: return "diskette changed or removed"; 00062 case 0x07: return "bad fixed disk parameter table"; 00063 case 0x08: return "DMA overrun"; 00064 case 0x09: return "DMA access across 64k boundary"; 00065 case 0x0A: return "bad fixed disk sector flag"; 00066 case 0x0B: return "bad fixed disk cylinder"; 00067 case 0x0C: return "unsupported track/invalid media"; 00068 case 0x0D: return "invalid number of sectors on fixed disk format"; 00069 case 0x0E: return "fixed disk controlled data address mark detected"; 00070 case 0x0F: return "fixed disk DMA arbitration level out of range"; 00071 case 0x10: return "ECC/CRC error on disk read"; 00072 case 0x11: return "recoverable fixed disk data error, data fixed by ECC"; 00073 case 0x20: return "controller error (NEC for floppies)"; 00074 case 0x40: return "seek failure"; 00075 case 0x80: return "time out, drive not ready"; 00076 case 0xAA: return "fixed disk drive not ready"; 00077 case 0xBB: return "fixed disk undefined error"; 00078 case 0xCC: return "fixed disk write fault on selected drive"; 00079 case 0xE0: return "fixed disk status error/Error reg = 0"; 00080 case 0xFF: return "sense operation failed"; 00081 00082 default: return "unknown error code"; 00083 } 00084 } 00085 00086 // This function is in arch/i386/i386disk.c 00087 //BOOLEAN DiskReadLogicalSectors(ULONG DriveNumber, U64 SectorNumber, ULONG SectorCount, PVOID Buffer) 00088 00089 BOOLEAN DiskIsDriveRemovable(UCHAR DriveNumber) 00090 { 00091 // Hard disks use drive numbers >= 0x80 00092 // So if the drive number indicates a hard disk 00093 // then return FALSE 00094 // 0x49 is our magic ramdisk drive, so return FALSE for that too 00095 if ((DriveNumber >= 0x80) || (DriveNumber == 0x49)) 00096 { 00097 return FALSE; 00098 } 00099 00100 // Drive is a floppy diskette so return TRUE 00101 return TRUE; 00102 } 00103 00104 BOOLEAN 00105 DiskGetBootPath(char *BootPath, unsigned Size) 00106 { 00107 static char Path[] = "multi(0)disk(0)"; 00108 char Device[4]; 00109 char Partition[4]; 00110 PARTITION_TABLE_ENTRY PartitionEntry; 00111 MASTER_BOOT_RECORD MasterBootRecord; 00112 00113 if (FrldrBootDrive < 0x80) 00114 { 00115 /* This is a floppy */ 00116 00117 if (Size <= sizeof(Path) + 7 + strlen(Device)) 00118 { 00119 return FALSE; 00120 } 00121 00122 strcpy(BootPath, Path); 00123 00124 strcat(BootPath, "fdisk"); 00125 00126 _itoa(FrldrBootDrive, Device, 10); 00127 strcat(BootPath, "("); 00128 strcat(BootPath, Device); 00129 strcat(BootPath, ")"); 00130 } 00131 /* FIXME */ 00132 else if (DiskReadBootRecord(FrldrBootDrive, 0, &MasterBootRecord)) 00133 { 00134 ULONG BootPartition; 00135 00136 /* This is a hard disk */ 00137 if (!DiskGetActivePartitionEntry(FrldrBootDrive, &PartitionEntry, &BootPartition)) 00138 { 00139 DbgPrint("Invalid active partition information\n"); 00140 return FALSE; 00141 } 00142 00143 FrldrBootPartition = BootPartition; 00144 00145 if (Size <= sizeof(Path) + 18 + strlen(Device) + strlen(Partition)) 00146 { 00147 return FALSE; 00148 } 00149 00150 strcpy(BootPath, Path); 00151 00152 strcat(BootPath, "rdisk"); 00153 00154 _itoa(FrldrBootDrive - 0x80, Device, 10); 00155 strcat(BootPath, "("); 00156 strcat(BootPath, Device); 00157 strcat(BootPath, ")"); 00158 00159 _itoa(FrldrBootPartition, Partition, 10); 00160 strcat(BootPath, "partition("); 00161 strcat(BootPath, Partition); 00162 strcat(BootPath, ")"); 00163 } 00164 else 00165 { 00166 /* This is a CD-ROM drive */ 00167 00168 if (Size <= sizeof(Path) + 7 + strlen(Device)) 00169 { 00170 return FALSE; 00171 } 00172 00173 strcpy(BootPath, Path); 00174 00175 strcat(BootPath, "cdrom"); 00176 00177 _itoa(FrldrBootDrive - 0x80, Device, 10); 00178 strcat(BootPath, "("); 00179 strcat(BootPath, Device); 00180 strcat(BootPath, ")"); 00181 } 00182 00183 return TRUE; 00184 } 00185 00186 // This function is in arch/i386/i386disk.c 00187 //VOID DiskStopFloppyMotor(VOID) 00188 00189 // This function is in arch/i386/i386disk.c 00190 //ULONG DiskGetCacheableBlockCount(UCHAR DriveNumber) 00191 00192 #endif Generated on Thu May 24 2012 04:19:11 for ReactOS by
1.7.6.1
|