- Timestamp:
- Feb 22, 2012, 7:01:53 PM (13 years ago)
- google:author:
- gregli@hotmail.com
- Location:
- trunk
- Files:
-
- 36 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Assembly_Library/Inc/Macros.inc
r119 r258 52 52 ; when stack usage is undesirable (ie speed is critical). 53 53 ; 54 ; The PRESERVE_FLAGS version will zero the register with a MOV instead 55 ; of an XOR, thus preserving the flags. It is one byte larger on 56 ; non-186 or higher systems. 57 ; 54 58 ; LOAD_BDA_SEGMENT_TO 59 ; LOAD_BDA_SEGMENT_PRESERVE_FLAGS_TO 55 60 ; Parameters: 56 61 ; %1: Destination Segment Register … … 68 73 %elifidn %3, ! 69 74 xor %2, %2 75 mov %1, %2 76 %else 77 push BYTE 0 78 pop %1 79 %endif 80 %endmacro 81 82 %macro LOAD_BDA_SEGMENT_PRESERVE_FLAGS_TO 2-3 83 %ifndef USE_186 84 mov %2, 0 85 mov %1, %2 86 %elifidn %3, ! 87 mov %2, 0 70 88 mov %1, %2 71 89 %else -
trunk/Serial_Server/library/Image.cpp
r233 r258 12 12 #include <stdio.h> 13 13 14 struct floppyInfo { 15 unsigned long size; 16 unsigned char type; 17 unsigned char cylinders; 18 unsigned char heads; 19 unsigned char sectors; 20 } floppyInfos[] = 21 { 22 { 2949120 / 512, 6, 80, 2, 36 }, // 2.88MB 3.5" 23 { 1474560 / 512, 4, 80, 2, 18 }, // 1.44MB 3.5" 24 { 1228800 / 512, 2, 80, 2, 15 }, // 1.2MB 5.25" 25 { 737280 / 512, 3, 80, 1, 18 }, // 720KB 3.5" 26 { 368640 / 512, 1, 40, 2, 9 }, // 360KB 5.25" 27 { 327680 / 512, 0, 40, 2, 8 }, // 320KB 5.25" 28 { 184320 / 512, 0, 40, 1, 9 }, // 180KB 5.25" single sided 29 { 163840 / 512, 0, 40, 1, 8 }, // 160KB 5.25" single sided 30 { 0, 0, 0, 0, 0 } 31 }; 32 14 33 Image::Image( char *name, int p_readOnly, int p_drive ) 15 34 { … … 27 46 { 28 47 double sizef; 48 char sizeChar; 49 struct floppyInfo *f; 29 50 30 51 for( char *c = shortFileName = name; *c; c++ ) … … 46 67 if( totallba == 0 ) 47 68 log( -1, "'%s', Image size zero?" ); 69 70 floppy = 0; 71 for( f = floppyInfos; f->size && f->size != totallba; f++ ) ; 72 if( f->size ) 73 { 74 floppy = 1; 75 floppyType = f->type; 76 p_useCHS = 1; 77 p_cyl = f->cylinders; 78 p_head = f->heads; 79 p_sect = f->sectors; 80 } 48 81 49 82 if( p_useCHS ) … … 82 115 83 116 sizef = totallba/2048.0; 117 sizeChar = 'M'; 118 if( sizef < 1 ) 119 { 120 sizef *= 1024; 121 sizeChar = 'K'; 122 } 84 123 if( useCHS ) 85 log( 0, "Opening '%s', CHS geometry %u:%u:%u, total LBA %lu, total size %.1lf MB", name, cyl, sect, head, totallba, sizef ); 86 else 87 log( 0, "Opening '%s', total LBA %lu, total size %.1lf MB", name, totallba, sizef ); 124 log( 0, "%s: %s with CHS geometry %u:%u:%u, size %.2lf %cB", 125 name, (floppy ? "Floppy Disk" : "Hard Disk"), cyl, head, sect, sizef, sizeChar ); 126 else 127 log( 0, "%s: %s with total sectors %lu, size %.2lf %cB", 128 name, (floppy ? "Floppy Disk" : "Hard Disk"), totallba, sizef, sizeChar ); 88 129 } 89 130 … … 137 178 #define ATA_dwLBACnt 60 138 179 139 #define ATA_wVendor 159 140 180 // Words carved out of the vendor specific area for our use 181 // 182 #define ATA_wSerialFloppyFlagAndType 158 183 #define ATA_wSerialPortAndBaud 159 184 185 // Defines used in the words above 186 // 141 187 #define ATA_wCaps_LBA 0x200 142 188 143 189 #define ATA_wGenCfg_FIXED 0x40 190 191 #define ATA_wSerialFloppyFlagAndType_Flag 0x10 192 #define ATA_wSerialFloppyFlagAndType_TypePosition 5 144 193 145 194 struct comPorts { … … 207 256 } 208 257 258 if( floppy ) 259 buff[ ATA_wSerialFloppyFlagAndType ] = ATA_wSerialFloppyFlagAndType_Flag | (floppyType << ATA_wSerialFloppyFlagAndType_TypePosition); 260 261 // we always set this, so that the bulk of the BIOS will consider this disk as a hard disk 262 // 209 263 buff[ ATA_wGenCfg ] = ATA_wGenCfg_FIXED; 210 // buff[ ATA_VendorSpecific_ReturnPortBaud ] = retWord; 211 } 264 } -
trunk/Serial_Server/library/Library.h
r233 r258 32 32 33 33 unsigned long cyl, sect, head; 34 unsigned char floppy, floppyType; 34 35 int useCHS; 35 36 -
trunk/Serial_Server/library/Process.cpp
r233 r258 99 99 lastScan = 0; 100 100 101 // 102 // Floppy disks must come after any hard disks 103 // 104 if( (image0 && image0->floppy) && (image1 && !image1->floppy) ) 105 { 106 img = image0; 107 image0 = image1; 108 image1 = img; 109 } 110 101 111 lasttick = GetTime(); 102 112 -
trunk/Serial_Server/win32/Win32.cpp
r233 r258 30 30 " -n [megabytes] Create new disk with given size or use -g geometry", 31 31 " Maximum size is " USAGE_MAXSECTORS, 32 " (default is a 32 MB disk, with CHS geometry 65:63:16)", 33 "", 34 " -p Named Pipe mode for emulators (pipe is \"" PIPENAME "\")", 35 "", 36 " -c COMPortNumber COM Port to use (default is first found)", 32 " (default is a 32 MB disk, with CHS geometry 65:16:63)", 33 "", 34 " -p [pipename] Named Pipe mode for emulators", 35 " (must begin with \"\\\\\", default is \"" PIPENAME "\")", 36 "", 37 " -c COMPortNumber COM Port to use (default is first found)", 38 " Available COM ports on this system are:", 39 "COM ", 37 40 "", 38 41 " -b BaudRate Baud rate to use on the COM port, with client machine", … … 53 56 "with xtidecfg.com. Or one can hold down the ALT key at the end of the normal", 54 57 "IDE hard disk scan and the XTIDE Universal BIOS will scan COM1-7, at each of", 55 "the fourspeeds given above for BaudRate. Note that hardware rate multipliers",58 "the six speeds given above for BaudRate. Note that hardware rate multipliers", 56 59 "must be taken into account on the server end, but are invisible on the client.", 60 "", 61 "Floppy images may also be used. Image size must be exactly the same size", 62 "as a 2.88MB, 1.44MB, 1.2MB, 720KB, 360KB, 320KB, 180KB, or 160KB disk.", 63 "Floppy images must be the last disks discovered by the BIOS, and only", 64 "two floppy drives are supported by the BIOS at a time.", 57 65 NULL }; 58 66 59 67 for( int t = 0; usageStrings[t]; t++ ) 60 fprintf( stderr, "%s\n", usageStrings[t] ); 68 { 69 if( !strncmp( usageStrings[t], "COM", 3 ) ) 70 { 71 char logbuff[ 1024 ]; 72 73 SerialAccess::EnumerateCOMPorts( logbuff, 1024 ); 74 fprintf( stderr, "%s%s\n", usageStrings[t]+3, logbuff ); 75 } 76 else 77 fprintf( stderr, "%s\n", usageStrings[t] ); 78 } 61 79 62 80 exit( 1 ); … … 120 138 break; 121 139 case 'p': case 'P': 122 ComPort = "PIPE"; 140 if( argv[t+1][0] == '\\' && argv[t+1][1] == '\\' ) 141 ComPort = argv[++t]; 142 else 143 ComPort = PIPENAME; 123 144 if( !baudRate ) 124 145 baudRate = baudRateMatchString( "115200" ); -
trunk/Serial_Server/win32/Win32Serial.h
r233 r258 35 35 } 36 36 37 if( !strcmp( name, "PIPE" ))37 if( name[0] == '\\' && name[1] == '\\' ) 38 38 { 39 log( 0, "Opening named pipe %s (simulating %s baud)", PIPENAME, baudRate->display );39 log( 0, "Opening named pipe %s (simulating %s baud)", name, baudRate->display ); 40 40 41 pipe = CreateNamedPipeA( PIPENAME, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE|PIPE_REJECT_REMOTE_CLIENTS, 2, 1024, 1024, 0, NULL );41 pipe = CreateNamedPipeA( name, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE|PIPE_REJECT_REMOTE_CLIENTS, 2, 1024, 1024, 0, NULL ); 42 42 if( pipe == INVALID_HANDLE_VALUE ) 43 43 log( -1, "Could not CreateNamedPipe " PIPENAME ); … … 59 59 DCB dcb; 60 60 61 log( 0, "Opening %s (% lu baud)", name, baudRate->rate);61 log( 0, "Opening %s (%s baud)", name, baudRate->display ); 62 62 63 63 pipe = CreateFileA( name, GENERIC_READ|GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 ); … … 74 74 dcb.Parity = NOPARITY; 75 75 if( !SetCommState( pipe, &dcb ) ) 76 log( -1, "Could not SetCommState" ); 76 { 77 char *msg = ""; 78 COMMPROP comProp; 79 80 if( GetCommProperties( pipe, &comProp ) ) 81 { 82 if( comProp.dwMaxBaud != BAUD_USER ) 83 msg = "\n On this COM port, baud rate is limited to 115.2K"; 84 } 85 log( -1, "Could not SetCommState: baud rate selected may not be availabele%s", msg ); 86 } 77 87 78 88 if( !SetCommTimeouts( pipe, &timeouts ) ) … … 82 92 { 83 93 char logbuff[ 1024 ]; 84 int found = 0;85 94 86 sprintf( logbuff, "serial port '%s' not found, detected COM ports:", name ); 87 88 for( int t = 1; t <= 40; t++ ) 89 { 90 sprintf( buff1, "COM%d", t ); 91 if( QueryDosDeviceA( buff1, buff2, sizeof(buff2) ) ) 92 { 93 strcat( logbuff, "\n " ); 94 strcat( logbuff, buff1 ); 95 found = 1; 96 } 97 } 98 if( !found ) 99 strcat( logbuff, "\n (none)" ); 95 EnumerateCOMPorts( logbuff, 1024 ); 100 96 101 log( -1, logbuff );97 log( -1, "Serial port '%s' not found, detected COM ports: %s", name, logbuff ); 102 98 } 103 99 } 100 } 101 102 static void EnumerateCOMPorts( char *logbuff, int logbuffLen ) 103 { 104 int found = 0; 105 char buff1[20], buff2[1024]; 106 107 logbuff[0] = 0; 108 109 for( int t = 1; t <= 40 && strlen(logbuff) < (logbuffLen - 40); t++ ) 110 { 111 sprintf( buff1, "COM%d", t ); 112 if( QueryDosDeviceA( buff1, buff2, sizeof(buff2) ) ) 113 { 114 if( found ) 115 strcat( logbuff, ", " ); 116 strcat( logbuff, buff1 ); 117 found = 1; 118 } 119 } 120 121 if( !found ) 122 strcat( logbuff, "(none)" ); 104 123 } 105 124 -
trunk/XTIDE_Universal_BIOS/Inc/ATA_ID.inc
r233 r258 254 254 .wRMSN resw 1 ; 127F, Removable Media Status Notification feature set support 255 255 .wSecurity resw 1 ; 128FV, Security Status 256 resw 159-129 ; 129...158X, Vendor Specific 257 .wVendor resw 1 ; 159X, Vendor Specific - picking one word for use by the Serial Port code 256 resw 158-129 ; 129...157X, Vendor Specific 257 .wSerialFloppyFlagAndType: 258 .wVendor1 resw 1 ; 158x, Vendor specific - word for use by the serial port code 259 .wSerialPortAndBaud: 260 .wVendor2 resw 1 ; 159X, Vendor Specific - word for use by the Serial Port code 258 261 .wCFAPower resw 1 ; 160FV, CFA Power Mode 1 259 262 resw 176-161 ; 161...175R, Reserved for assignment by the CompactFlash Association -
trunk/XTIDE_Universal_BIOS/Inc/CustomDPT.inc
r238 r258 68 68 MASKH_DPT_RESET EQU 0F0h 69 69 70 FLGH_DPT_SERIAL_FLOPPY EQU (1<<4) 71 FLGH_DPT_SERIAL_FLOPPY_TYPE_MASK EQU 0e0h 72 FLGH_DPT_SERIAL_FLOPPY_TYPE_FIELD_POSITION EQU 5 73 70 74 ; Addressing modes for DPT.wFlags 71 75 ADDRESSING_MODE_FIELD_POSITION EQU 5 -
trunk/XTIDE_Universal_BIOS/Inc/RamVars.inc
r248 r258 11 11 struc XLATEVARS 12 12 .wFDandHDswap: 13 .bFDSwap resb 1 ; Floppy Drive to swap to 00h and vice versa 14 .bHDSwap resb 1 ; Hard Drive to swap to 80h and vice versa 15 .bXlatedDrv resb 1 ; Drive number after translation 16 resb 1 ; alignment 13 .bFDSwap resb 1 ; Floppy Drive to swap to 00h and vice versa 14 .bHDSwap resb 1 ; Hard Drive to swap to 80h and vice versa 15 .bXlatedDrv resb 1 ; Drive number after translation 16 %ifdef MODULE_SERIAL_FLOPPY 17 .bFlopCreateCnt: 18 .bFlopCntAndFirst resb 1 ; Normally, packed starting floppy drive number (high order 7 bits) 19 ; and number of drives (low order bit, max 2 drives supported). 20 ; During initialization, until the end of DetectDrives_FromAllIDEControllers, 21 ; this byte contains the raw number of floppy drives seen (using .bFlopCreateCnt) 22 %else 23 resb 1 ; alignment 24 %endif 17 25 endstruc 18 26 … … 27 35 28 36 .wDrvCntAndFirst: 37 .bFirstDrv resb 1 ; Number of first drive for this BIOS 29 38 .bDrvCnt resb 1 ; Number of drives handled by this BIOS 30 .bFirstDrv resb 1 ; Number of first drive for this BIOS31 39 32 40 ; Variables for drive number translation -
trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenu.asm
r248 r258 37 37 ; Clear: There is no selected menu item, DL is not valid 38 38 ; Corrupts registers: 39 ; CX, DI39 ; AX, DI 40 40 ;-------------------------------------------------------------------- 41 41 ALIGN JUMP_ALIGN … … 50 50 51 51 mov dl, cl ; Copy menuitem index to DX 52 call FloppyDrive_GetCountTo CX53 cmp dl, cl ; Floppy drive?52 call FloppyDrive_GetCountToAX 53 cmp dl, al ; Floppy drive? 54 54 jb SHORT .ReturnFloppyDriveInDX ; Set CF if branch taken 55 or cl, 80h ; Or 80h into CL before the sub55 or al, 80h ; Or 80h into AL before the sub 56 56 ; to cause CF to be set after 57 57 ; and result has high order bit set 58 sub dl, cl ; Remove floppy drives from index58 sub dl, al ; Remove floppy drives from index 59 59 60 60 .ReturnFloppyDriveInDX: … … 94 94 ALIGN JUMP_ALIGN 95 95 BootMenu_GetMenuitemCountToAX: 96 call RamVars_GetHardDiskCountFromBDAto CX96 call RamVars_GetHardDiskCountFromBDAtoAX 97 97 xchg ax, cx 98 call FloppyDrive_GetCountTo CX98 call FloppyDrive_GetCountToAX 99 99 add ax, cx 100 100 ret … … 136 136 BootMenu_GetMenuitemToAXforAsciiHotkeyInAL: 137 137 call Char_ALtoUpperCaseLetter 138 call BootMenu_GetLetterForFirstHardDiskToCL139 138 xor ah, ah 140 cmp al, cl ; Letter is for Hard Disk? 139 xchg ax, cx 140 call BootMenu_GetLetterForFirstHardDiskToAL 141 cmp cl, al ; Letter is for Hard Disk? 141 142 jae SHORT .StartFromHardDiskLetter 143 xchg ax, cx 142 144 sub al, 'A' ; Letter to Floppy Drive menuitem 143 145 ret 144 146 ALIGN JUMP_ALIGN 145 147 .StartFromHardDiskLetter: 146 sub al, cl ; Hard Disk index147 call FloppyDrive_GetCountTo CX148 sub cl, al ; Hard Disk index 149 call FloppyDrive_GetCountToAX 148 150 add ax, cx ; Menuitem index 151 ; Note: no need to xchg ax, cx as above, since adding with result to ax 149 152 ret 150 153 … … 160 163 ; CL: Upper case letter for first hard disk 161 164 ; Corrupts registers: 162 ; CH163 ;-------------------------------------------------------------------- 164 ALIGN JUMP_ALIGN 165 BootMenu_GetLetterForFirstHardDiskTo CL:166 call FloppyDrive_GetCountTo CX167 add cl, 'A'168 cmp cl, 'C'165 ; AX 166 ;-------------------------------------------------------------------- 167 ALIGN JUMP_ALIGN 168 BootMenu_GetLetterForFirstHardDiskToAL: 169 call FloppyDrive_GetCountToAX 170 add al, 'A' 171 cmp al, 'C' 169 172 ja .Return 170 mov cl, 'C'173 mov al, 'C' 171 174 ALIGN JUMP_ALIGN, ret 172 175 .Return: … … 181 184 ; DX: Menuitem index (assuming drive is available) 182 185 ; Corrupts registers: 183 ; Nothing186 ; AX 184 187 ;-------------------------------------------------------------------- 185 188 ALIGN JUMP_ALIGN … … 188 191 test dl, dl 189 192 jns SHORT .ReturnItemIndexInDX ; Return if floppy drive (HD bit not set) 190 call FloppyDrive_GetCountTo CX193 call FloppyDrive_GetCountToAX 191 194 and dl, ~80h ; Clear HD bit 192 add dx, cx195 add dx, ax 193 196 .ReturnItemIndexInDX: 194 197 ret … … 212 215 test dl, dl ; Floppy drive? 213 216 jns SHORT .IsFloppyDriveInSystem 214 call RamVars_GetHardDiskCountFromBDAto CX ; Hard Disk count to CX215 or cl, 80h ; Set Hard Disk bit to CX217 call RamVars_GetHardDiskCountFromBDAtoAX ; Hard Disk count to AX 218 or al, 80h ; Set Hard Disk bit to AX 216 219 jmp SHORT .CompareDriveNumberToDriveCount 217 220 .IsFloppyDriveInSystem: 218 call FloppyDrive_GetCountTo CX221 call FloppyDrive_GetCountToAX 219 222 .CompareDriveNumberToDriveCount: 220 cmp dl, cl ; Set CF when DL is smaller221 ret 223 cmp dl, al ; Set CF when DL is smaller 224 ret -
trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuEvent.asm
r248 r258 21 21 %ifdef MENUEVENT_INLINE_OFFSETS 22 22 23 add bx, BootMenuEvent_Handler 23 add bx, BootMenuEvent_Handler.FirstEvent 24 24 jmp bx 25 25 26 MENUEVENT_InitializeMenuinitFromDSSI equ (BootMenuEvent_Handler.InitializeMenuinitFromDSSI - BootMenuEvent_Handler )27 MENUEVENT_ExitMenu equ (BootMenuEvent_EventCompleted - BootMenuEvent_Handler )28 MENUEVENT_ItemHighlightedFromCX equ (BootMenuEvent_Handler.ItemHighlightedFromCX - BootMenuEvent_Handler )29 MENUEVENT_ItemSelectedFromCX equ (BootMenuEvent_Handler.ItemSelectedFromCX - BootMenuEvent_Handler )30 MENUEVENT_KeyStrokeInAX equ (BootMenuEvent_Handler.KeyStrokeInAX - BootMenuEvent_Handler )31 MENUEVENT_RefreshTitle equ (BootMenuPrint_TitleStrings - BootMenuEvent_Handler )32 MENUEVENT_RefreshInformation equ (BootMenuPrint_RefreshInformation - BootMenuEvent_Handler )33 MENUEVENT_RefreshItemFromCX equ (BootMenuPrint_RefreshItem - BootMenuEvent_Handler )26 MENUEVENT_InitializeMenuinitFromDSSI equ (BootMenuEvent_Handler.InitializeMenuinitFromDSSI - BootMenuEvent_Handler.FirstEvent) 27 MENUEVENT_ExitMenu equ (BootMenuEvent_EventCompleted - BootMenuEvent_Handler.FirstEvent) 28 MENUEVENT_ItemHighlightedFromCX equ (BootMenuEvent_Handler.ItemHighlightedFromCX - BootMenuEvent_Handler.FirstEvent) 29 MENUEVENT_ItemSelectedFromCX equ (BootMenuEvent_Handler.ItemSelectedFromCX - BootMenuEvent_Handler.FirstEvent) 30 MENUEVENT_KeyStrokeInAX equ (BootMenuEvent_Handler.KeyStrokeInAX - BootMenuEvent_Handler.FirstEvent) 31 MENUEVENT_RefreshTitle equ (BootMenuPrint_TitleStrings - BootMenuEvent_Handler.FirstEvent) 32 MENUEVENT_RefreshInformation equ (BootMenuPrint_RefreshInformation - BootMenuEvent_Handler.FirstEvent) 33 MENUEVENT_RefreshItemFromCX equ (BootMenuPrint_RefreshItem - BootMenuEvent_Handler.FirstEvent) 34 34 ; 35 35 ; Note that there is no entry for MENUEVENT_IdleProcessing. If MENUEVENT_IDLEPROCESSING_ENABLE is not %defined, … … 67 67 ; DS:SI: Ptr to initialized MENUINIT struct 68 68 ALIGN JUMP_ALIGN 69 .FirstEvent: 69 70 .InitializeMenuinitFromDSSI: 70 71 push ds -
trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrint.asm
r255 r258 24 24 25 25 call RamVars_IsDriveHandledByThisBIOS 26 j nc .notOurs26 jc .notOurs 27 27 28 28 call FindDPT_ForDriveNumber ; if it is one of ours, print the string in bootnfo … … 47 47 push ax ; the hard disks don't ever use it, but it does no harm) 48 48 49 jmp short BootMenuPrint_ FormatCSSIfromParamsInSSBP49 jmp short BootMenuPrint_RefreshInformation.FormatRelay 50 50 51 51 ;-------------------------------------------------------------------- … … 87 87 push bp 88 88 mov bp,sp 89 jmp short BootMenuPrint_ FormatCSSIfromParamsInSSBP89 jmp short BootMenuPrint_RefreshInformation.FormatRelay 90 90 91 91 … … 110 110 mov bp, sp 111 111 112 mov si, g_szCapacity ; Setup print string now, carries through to print call 113 114 xor di, di 115 call RamVars_IsDriveHandledByThisBIOS 116 jc SHORT .notours 117 call FindDPT_ForDriveNumber ; DS:DI to point DPT 118 .notours: 119 112 120 test dl, dl ; are we a hard disk? 113 121 js BootMenuPrint_HardDiskRefreshInformation 114 122 123 test di,di 124 jnz .ours 115 125 call FloppyDrive_GetType ; Get Floppy Drive type to BX 126 jmp .around 127 .ours: 128 call AH8h_GetDriveParameters 129 .around: 116 130 117 131 mov ax, g_szFddSizeOr ; .PrintXTFloppyType 118 test b x, bx; Two possibilities? (FLOPPY_TYPE_525_OR_35_DD)132 test bl, bl ; Two possibilities? (FLOPPY_TYPE_525_OR_35_DD) 119 133 jz SHORT .PushAXAndOutput 120 134 … … 158 172 159 173 mov al,FloppyTypes.rgbCapacityMultiplier 174 mov bh, 0 160 175 mul byte [cs:bx+FloppyTypes.rgbCapacity - 1] ; -1 since 0 is handled above and not in the table 161 176 … … 163 178 push ax 164 179 165 jmp short BootMenuPrint_HardDiskRefreshInformation.output 180 .FormatRelay: 181 jmp short BootMenuPrint_FormatCSSIfromParamsInSSBP 166 182 167 183 … … 180 196 ALIGN JUMP_ALIGN 181 197 BootMenuPrint_HardDiskRefreshInformation: 182 call RamVars_IsDriveHandledByThisBIOS 183 jnc SHORT .HardDiskMenuitemInfoForForeignDrive 184 call FindDPT_ForDriveNumber ; DS:DI to point DPT 185 ; Fall to .HardDiskMenuitemInfoForOurDrive 186 187 ;-------------------------------------------------------------------- 188 ; .HardDiskMenuitemInfoForOurDrive 189 ; Parameters: 190 ; DL: Untranslated Hard Disk number 191 ; DS:DI: Ptr to DPT 192 ; Returns: 193 ; Nothing 194 ; Corrupts registers: 195 ; AX, BX, CX, DX, SI, DI, ES 196 ;-------------------------------------------------------------------- 198 test di,di 199 jz .HardDiskMenuitemInfoForForeignDrive 200 197 201 .HardDiskMenuitemInfoForOurDrive: 198 202 ePUSH_T ax, g_szInformation … … 200 204 ; Get and push total LBA size 201 205 call BootMenuInfo_GetTotalSectorCount 202 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat 203 jmp BootMenuPrintCfg_ForOurDrive 204 205 ;-------------------------------------------------------------------- 206 ; .HardDiskMenuitemInfoForForeignDrive 207 ; Parameters: 208 ; DL: Untranslated Hard Disk number 209 ; DS: RAMVARS segment 210 ; Returns: 211 ; CF: Set since menu event was handled successfully 212 ; Corrupts registers: 213 ; AX, BX, CX, DX, SI, DI 214 ;-------------------------------------------------------------------- 215 ALIGN JUMP_ALIGN 206 jmp .ConvertSectorCountInBXDXAXtoSizeAndPushForFormat 207 216 208 .HardDiskMenuitemInfoForForeignDrive: 217 209 call DriveXlate_ToOrBack 218 210 call AH15h_GetSectorCountFromForeignDriveToDXAX 219 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat 220 221 ALIGN JUMP_ALIGN 222 .output: 223 mov si, g_szCapacity 224 ;;; fall-through 211 212 .ConvertSectorCountInBXDXAXtoSizeAndPushForFormat: 213 ePUSH_T cx, g_szCapacityNum ; Push format substring 214 call Size_ConvertSectorCountInBXDXAXtoKiB 215 mov cx, BYTE_MULTIPLES.kiB 216 call Size_GetSizeToAXAndCharToDLfromBXDXAXwithMagnitudeInCX 217 push ax ; Size in magnitude 218 push cx ; Tenths 219 push dx ; Magnitude character 220 221 test di,di 222 jz short BootMenuPrint_FormatCSSIfromParamsInSSBP 223 224 %include "BootMenuPrintCfg.asm" ; inline of code to fill out remainder of information string 225 226 ;;; fall-through to BootMenuPrint_FormatCSSIfromParamsInSSBP 227 225 228 226 229 ;-------------------------------------------------------------------- … … 273 276 ALIGN JUMP_ALIGN 274 277 BootMenuPrint_TheBottomOfScreen: 275 call FloppyDrive_GetCountTo CX276 mov bl, cl; Floppy Drive count to BL277 call RamVars_GetHardDiskCountFromBDAto CX278 mov bh, cl ; Hard Disk count to BH278 call FloppyDrive_GetCountToAX 279 xchg bx, ax ; Floppy Drive count to BL 280 call RamVars_GetHardDiskCountFromBDAtoAX 281 mov bh, al ; Hard Disk count to BH 279 282 ; Fall to .MoveCursorToHotkeyStrings 280 283 … … 321 324 test bh, bh ; Any Hard Drives? 322 325 jz SHORT .SkipHardDriveHotkeys 323 xchg ax, cx ; Store Key Attribute 324 call BootMenu_GetLetterForFirstHardDiskToCL 325 mov ch, ANGLE_QUOTE_RIGHT 326 xchg ax, cx 326 call BootMenu_GetLetterForFirstHardDiskToAL 327 mov ah, ANGLE_QUOTE_RIGHT 327 328 mov si, g_szHDD 328 329 call PushHotkeyParamsAndFormat … … 390 391 CALL_DISPLAY_LIBRARY InitializeDisplayContext 391 392 ret 392 393 394 ;--------------------------------------------------------------------395 ; ConvertSectorCountInBXDXAXtoSizeAndPushForFormat396 ; Parameters:397 ; BX:DX:AX: Sector count398 ; Returns:399 ; Size in stack400 ; Corrupts registers:401 ; AX, BX, CX, DX, SI402 ;--------------------------------------------------------------------403 ALIGN JUMP_ALIGN404 ConvertSectorCountInBXDXAXtoSizeAndPushForFormat:405 pop si ; Pop return address406 ePUSH_T cx, g_szCapacityNum ; Push format substring407 call Size_ConvertSectorCountInBXDXAXtoKiB408 mov cx, BYTE_MULTIPLES.kiB409 call Size_GetSizeToAXAndCharToDLfromBXDXAXwithMagnitudeInCX410 push ax ; Size in magnitude411 push cx ; Tenths412 push dx ; Magnitude character413 jmp si414 393 415 394 -
trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrintCfg.asm
r241 r258 2 2 ; Description : Functions for printing drive configuration 3 3 ; information on Boot Menu. 4 4 ; 5 ; Included by BootMenuPrint.asm, this routine is to be inserted into 6 ; BootMenuPrint_HardDiskRefreshInformation. 7 ; 5 8 ; Section containing code 6 9 SECTION .text 10 11 ;;; fall-into from BootMenuPrint_HardDiskRefreshInformation. 7 12 8 13 ;-------------------------------------------------------------------- … … 16 21 ; Nothing 17 22 ; Corrupts registers: 18 ; AX, BX, CX, DX , SI, DI23 ; AX, BX, CX, DX 19 24 ;-------------------------------------------------------------------- 20 ALIGN JUMP_ALIGN 21 BootMenuPrintCfg_ForOurDrive: 25 .BootMenuPrintCfg_ForOurDrive: 22 26 eMOVZX ax, BYTE [di+DPT.bIdevarsOffset] 23 xchg si, ax ; CS:SInow points to IDEVARS27 xchg bx, ax ; CS:BX now points to IDEVARS 24 28 ; Fall to .PushAndFormatCfgString 25 29 … … 28 32 ; Parameters: 29 33 ; DS:DI: Ptr to DPT 30 ; CS: SI: Ptr to IDEVARS34 ; CS:BX: Ptr to IDEVARS 31 35 ; Returns: 32 36 ; Nothing (jumps to next push below) 33 37 ; Corrupts registers: 34 ; AX, BX38 ; AX, CX 35 39 ;-------------------------------------------------------------------- 36 40 .PushAddressingMode: … … 41 45 ;; with AL clear, and so we exchange AL and AH after the multiply for the final result. 42 46 ;; 43 mov bl,(1<<(8-ADDRESSING_MODE_FIELD_POSITION)) * g_szAddressingModes_Displacement44 mul bl47 mov cl,(1<<(8-ADDRESSING_MODE_FIELD_POSITION)) * g_szAddressingModes_Displacement 48 mul cl 45 49 xchg al,ah 46 50 add ax,g_szAddressingModes … … 51 55 ; Parameters: 52 56 ; DS:DI: Ptr to DPT 53 ; CS: SI: Ptr to IDEVARS57 ; CS:BX: Ptr to IDEVARS 54 58 ; Returns: 55 59 ; Nothing (falls to next push below) … … 69 73 ; Parameters: 70 74 ; DS:DI: Ptr to DPT 71 ; CS: SI: Ptr to IDEVARS75 ; CS:BX: Ptr to IDEVARS 72 76 ; Returns: 73 77 ; Nothing (jumps to next push below) … … 77 81 .PushBusType: 78 82 mov al,g_szBusTypeValues_Displacement 79 mul BYTE [cs: si+IDEVARS.bDevice]83 mul BYTE [cs:bx+IDEVARS.bDevice] 80 84 81 85 shr ax,1 ; divide by 2 since IDEVARS.bDevice is multiplied by 2 … … 88 92 ; Parameters: 89 93 ; DS:DI: Ptr to DPT 90 ; CS: SI: Ptr to IDEVARS94 ; CS:BX: Ptr to IDEVARS 91 95 ; Returns: 92 96 ; Nothing (falls to next push below) … … 95 99 ;-------------------------------------------------------------------- 96 100 .PushIRQ: 97 mov al, BYTE [cs: si+IDEVARS.bIRQ]101 mov al, BYTE [cs:bx+IDEVARS.bIRQ] 98 102 cbw 99 103 push ax … … 103 107 ; Parameters: 104 108 ; DS:DI: Ptr to DPT 105 ; CS: SI: Ptr to IDEVARS109 ; CS:BX: Ptr to IDEVARS 106 110 ; Returns: 107 111 ; Nothing (falls to next push below) … … 114 118 push ax 115 119 116 ;-------------------------------------------------------------------- 117 ; PrintValuesFromStack 118 ; Parameters: 119 ; Stack: All formatting parameters 120 ; Returns: 121 ; Nothing 122 ; Corrupts registers: 123 ; AX, SI, DI 124 ;-------------------------------------------------------------------- 125 .PrintValuesFromStack: 126 jmp BootMenuPrint_HardDiskRefreshInformation.output 127 120 ;;; fall-out to BootMenuPrint_HardDiskRefreshInformation. -
trunk/XTIDE_Universal_BIOS/Src/Device/Device.asm
r249 r258 37 37 %ifdef MODULE_SERIAL 38 38 Device_FinalizeDPT: 39 TEST_USIGN_DPT_AND_JUMP_IF_SERIAL_DEVICE .FinalizeDptForSerialPortDevice 39 ; needs to check IDEVARS vs. checking the DPT as the serial bit in the DPT is set in the Finalize routine 40 CMP_USING_IDEVARS_IN_CSBP_AND_JUMP_IF DEVICE_SERIAL_PORT, .FinalizeDptForSerialPortDevice 40 41 jmp IdeDPT_Finalize 41 .FinalizeDptForSerialPortDevice: 42 .FinalizeDptForSerialPortDevice: 42 43 jmp SerialDPT_Finalize 43 44 -
trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeDPT.asm
r242 r258 12 12 ; CS:BP: Ptr to IDEVARS for the controller 13 13 ; Returns: 14 ; Nothing14 ; CF: Clear, IDE interface only supports hard disks 15 15 ; Corrupts registers: 16 16 ; AX … … 42 42 ; CS:BP: Ptr to IDEVARS for the controller 43 43 ; Returns: 44 ; Nothing44 ; CF: Always clear, we don't support floppies on the IDE inteface 45 45 ; Corrupts registers: 46 46 ; Nothing … … 52 52 53 53 .EndDPT: 54 clc 54 55 ret -
trunk/XTIDE_Universal_BIOS/Src/Device/Serial/SerialCommand.asm
r242 r258 56 56 ; Returns: 57 57 ; AH: INT 13h Error Code 58 ; CX: Number of successfully transferred sectors (for transfer commands) 58 59 ; CF: Cleared if success, Set if error 59 60 ; Corrupts registers: … … 309 310 dec al ; decrement sector count 310 311 push ax ; save 311 jz SerialCommand_OutputWithParameters_ReturnCodeInAL CF ; CF=0 from "cmp ax,bp" returning Zero above312 jz SerialCommand_OutputWithParameters_ReturnCodeInAL 312 313 313 314 cli ; interrupts back off for ACK byte to host … … 409 410 410 411 .clearBufferComplete: 411 stc 412 mov al,1 413 414 ALIGN JUMP_ALIGN 415 SerialCommand_OutputWithParameters_ReturnCodeInALCF: 412 mov al, 3 ; error return code and CF (low order bit) 413 414 ALIGN JUMP_ALIGN 415 SerialCommand_OutputWithParameters_ReturnCodeInAL: 416 416 %if 0 417 417 sti ; all paths here will already have interrupts turned back on 418 418 %endif 419 mov ah, al420 421 pop b p ; recover ax (command and count) from stack, throw away419 mov ah, al ; for success, AL will already be zero 420 421 pop bx ; recover "ax" (command and count) from stack 422 422 423 423 pop bp 424 424 pop di 425 425 pop si 426 427 mov ch, 0 428 mov cl,[bp+IDEPACK.bSectorCount] 429 sub cl, bl ; subtract off the number of sectors that remained 430 431 shr ah, 1 ; shift down return code and CF 426 432 427 433 ret … … 632 638 call FindDPT_ToDSDIforSerialDevice 633 639 pop si 640 %ifdef MODULE_SERIAL_FLOPPY 641 jc .founddpt 642 ; 643 ; If not found above with FindDPT_ToDSDIforSerialDevice, DI will point to the DPT after the last hard disk DPT 644 ; 645 cmp byte [RAMVARS.xlateVars+XLATEVARS.bFlopCntAndFirst], 0 646 jz .notfounddpt 647 .founddpt: 648 %else 634 649 jnc .notfounddpt 650 %endif 635 651 mov ax, [di+DPT_SERIAL.wSerialPortAndBaud] 636 652 .notfounddpt: … … 678 694 ; which is read by FinalizeDPT and DetectDrives 679 695 ; 680 mov [es:si+ATA6.w Vendor],dx696 mov [es:si+ATA6.wSerialPortAndBaud],dx 681 697 682 698 .notFound: -
trunk/XTIDE_Universal_BIOS/Src/Device/Serial/SerialDPT.asm
r242 r258 11 11 ; ES:SI: Ptr to 512-byte ATA information read from the drive 12 12 ; Returns: 13 ; Nothing 13 ; CF: Set, indicates that this is a floppy disk 14 ; Clear, indicates that this is a hard disk 14 15 ; Corrupts registers: 15 16 ; AX 16 17 ;-------------------------------------------------------------------- 17 18 SerialDPT_Finalize: 18 or byte [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE 19 mov ax, [es:si+ATA6.wVendor] 19 mov ax, [es:si+ATA6.wSerialPortAndBaud] 20 20 mov [di+DPT_SERIAL.wSerialPortAndBaud], ax 21 22 ; 23 ; Note that this section is not under %ifdef MODULE_SERIAL_FLOPPY. It is important to 24 ; detect floppy disks presented by the server and not treat them like hard disks, even 25 ; if the floppy support is disabled. 26 ; 27 mov al, [es:si+ATA6.wSerialFloppyFlagAndType] 28 or al, FLGH_DPT_SERIAL_DEVICE 29 or byte [di+DPT.bFlagsHigh], al 30 31 test al, FLGH_DPT_SERIAL_FLOPPY ; clears CF 32 jz .notfloppy 33 stc 34 .notfloppy: 35 21 36 ret 22 37 -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm
r249 r258 29 29 mov [RAMVARS.xlateVars+XLATEVARS.bXlatedDrv], dl 30 30 call RamVars_IsFunctionHandledByThisBIOS 31 jnc SHORT Int13h_DirectCallToAnotherBios 31 jc SHORT Int13h_DirectCallToAnotherBios 32 32 33 call FindDPT_ForDriveNumber ; DS:DI now points to DPT 33 34 … … 139 140 ALIGN JUMP_ALIGN 140 141 Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH: 142 %ifdef MODULE_SERIAL_FLOPPY 143 mov al, [bp+IDEPACK.intpack+INTPACK.dl] 144 Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH_ALHasDriveNumber: 145 call Int13h_SetErrorCodeToBdaAndToIntpackInSSBPfromAH_ALHasDriveNumber 146 %else 141 147 call Int13h_SetErrorCodeToBdaAndToIntpackInSSBPfromAH 148 %endif 142 149 Int13h_ReturnFromHandlerWithoutStoringErrorCode: 143 150 or WORD [bp+IDEPACK.intpack+INTPACK.flags], FLG_FLAGS_IF ; Return with interrupts enabled … … 154 161 ; Returns: 155 162 ; Depends on function 163 ; NOTE: ES:DI needs to be returned from the previous interrupt 164 ; handler, for floppy DPT in function 08h 156 165 ; Corrupts registers: 157 ; BX, DI, ES166 ; None 158 167 ;-------------------------------------------------------------------- 159 168 ALIGN JUMP_ALIGN 160 169 Int13h_CallPreviousInt13hHandler: 161 push di162 170 call ExchangeCurrentInt13hHandlerWithOldInt13hHandler 163 171 int BIOS_DISK_INTERRUPT_13h 164 call ExchangeCurrentInt13hHandlerWithOldInt13hHandler 165 pop di 166 ret 167 172 ;;; fall-through to ExchangeCurrentInt13hHandlerWithOldInt13hHandler 168 173 169 174 ;-------------------------------------------------------------------- … … 174 179 ; Nothing 175 180 ; Corrupts registers: 176 ; DI 181 ; Nothing 182 ; Note: Flags are preserved 177 183 ;-------------------------------------------------------------------- 178 184 ALIGN JUMP_ALIGN 179 185 ExchangeCurrentInt13hHandlerWithOldInt13hHandler: 180 186 push es 181 LOAD_BDA_SEGMENT_TO es, di 182 mov di, [RAMVARS.fpOldI13h] 187 push si 188 LOAD_BDA_SEGMENT_PRESERVE_FLAGS_TO es, si 189 mov si, [RAMVARS.fpOldI13h] 183 190 cli 184 xchg di, [es:BIOS_DISK_INTERRUPT_13h*4]185 mov [RAMVARS.fpOldI13h], di186 mov di, [RAMVARS.fpOldI13h+2]187 xchg di, [es:BIOS_DISK_INTERRUPT_13h*4+2]191 xchg si, [es:BIOS_DISK_INTERRUPT_13h*4] 192 mov [RAMVARS.fpOldI13h], si 193 mov si, [RAMVARS.fpOldI13h+2] 194 xchg si, [es:BIOS_DISK_INTERRUPT_13h*4+2] 188 195 sti 189 mov [RAMVARS.fpOldI13h+2], di 196 mov [RAMVARS.fpOldI13h+2], si 197 pop si 190 198 pop es 191 199 ret … … 204 212 ;-------------------------------------------------------------------- 205 213 ALIGN JUMP_ALIGN 214 %ifdef MODULE_SERIAL_FLOPPY 215 Int13h_SetErrorCodeToBdaAndToIntpackInSSBPfromAH_ALHasDriveNumber: 216 ; Store error code to BDA 217 mov bx, BDA.bHDLastSt 218 test al, al 219 js .HardDisk 220 mov bl, BDA.bFDRetST & 0xff 221 .HardDisk: 222 LOAD_BDA_SEGMENT_TO ds, di 223 mov [bx], ah 224 %else 206 225 Int13h_SetErrorCodeToBdaAndToIntpackInSSBPfromAH: 207 226 ; Store error code to BDA 208 LOAD_BDA_SEGMENT_TO ds, di 227 LOAD_BDA_SEGMENT_TO ds, di 209 228 mov [BDA.bHDLastSt], ah 229 %endif 210 230 211 231 ; Store error code to INTPACK -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm
r152 r258 22 22 eMOVZX bx, dl ; Copy requested drive to BL, zero BH to assume no errors 23 23 call ResetFloppyDrivesWithInt40h 24 test bl, bl25 jns SHORT .SkipHardDiskReset26 24 call ResetForeignHardDisks 27 25 call AH0h_ResetHardDisksHandledByOurBIOS … … 64 62 xor ah, ah ; Disk Controller Reset 65 63 call Int13h_CallPreviousInt13hHandler 66 jmp SHORT BackupErrorCodeFromTheRequestedDriveToBH 67 64 ;;; fall-through to BackupErrorCodeFromTheRequestedDriveToBH 65 66 67 ;-------------------------------------------------------------------- 68 ; BackupErrorCodeFromTheRequestedDriveToBH 69 ; Parameters: 70 ; AH: Error code from the last resetted drive 71 ; DL: Drive last resetted 72 ; BL: Requested drive (DL when entering AH=00h) 73 ; Returns: 74 ; BH: Backuped error code 75 ; Corrupts registers: 76 ; Nothing 77 ;-------------------------------------------------------------------- 78 ALIGN JUMP_ALIGN 79 BackupErrorCodeFromTheRequestedDriveToBH: 80 cmp dl, bl ; Requested drive? 81 eCMOVE bh, ah 82 ret 83 68 84 69 85 ;-------------------------------------------------------------------- … … 82 98 mov dl, bl 83 99 call RamVars_IsDriveHandledByThisBIOS 84 j nc SHORT .Return ; Return what was in BL unmodified100 jc SHORT .Return ; Return what was in BL unmodified 85 101 mov dl, 80h 86 102 .Return: … … 101 117 ALIGN JUMP_ALIGN 102 118 AH0h_ResetHardDisksHandledByOurBIOS: 103 mov d h, [RAMVARS.bDrvCnt] ; Load drive count to DH119 mov dx, [RAMVARS.wDrvCntAndFirst] ; DL = drive number, DH = drive count 104 120 test dh, dh 105 121 jz SHORT .AllDrivesReset ; Return if no drives 106 mov dl, [RAMVARS.bFirstDrv] ; Load number of our first drive107 122 add dh, dl ; DH = one past last drive to reset 108 123 ALIGN JUMP_ALIGN … … 114 129 jb SHORT .DriveResetLoop ; If not, reset next drive 115 130 .AllDrivesReset: 116 ret 117 131 %ifdef MODULE_SERIAL_FLOPPY 132 ; 133 ; "Reset" emulatd serial floppy drives, if any. There is nothing to actually do for this reset, 134 ; but record the proper error return code if one of these floppy drives is the drive requested. 135 ; 136 call RamVars_UnpackFlopCntAndFirstToAL 137 138 cbw ; Clears AH (there are flop drives) or ffh (there are not) 139 ; Either AH has success code (flop drives are present) 140 ; or it doesn't matter because we won't match drive ffh 141 142 cwd ; clears DX (there are flop drives) or ffffh (there are not) 143 144 adc dl, al ; second drive (CF set) if present 145 ; If no drive is present, this will result in ffh which 146 ; won't match a drive 147 call BackupErrorCodeFromTheRequestedDriveToBH 148 mov dl, al ; We may end up doing the first drive twice (if there is 149 jmp BackupErrorCodeFromTheRequestedDriveToBH ; only one drive), but doing it again is not harmful. 150 %else 151 ret 152 %endif 153 118 154 ;-------------------------------------------------------------------- 119 155 ; .BackupErrorCodeFromMasterOrSlaveToBH … … 144 180 ret 145 181 182 146 183 ;-------------------------------------------------------------------- 147 184 ; GetBasePortToCX … … 167 204 168 205 169 ;--------------------------------------------------------------------170 ; BackupErrorCodeFromTheRequestedDriveToBH171 ; Parameters:172 ; AH: Error code from the last resetted drive173 ; DL: Drive last resetted174 ; BL: Requested drive (DL when entering AH=00h)175 ; Returns:176 ; BH: Backuped error code177 ; Corrupts registers:178 ; Nothing179 ;--------------------------------------------------------------------180 ALIGN JUMP_ALIGN181 BackupErrorCodeFromTheRequestedDriveToBH:182 cmp dl, bl ; Requested drive?183 eCMOVE bh, ah184 ret -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH15h_HSize.asm
r257 r258 15 15 ; Returns with INTPACK: 16 16 ; If succesfull: 17 ; AH: 3 (Hard disk accessible) 17 ; AH: Hard Disk: 3 (Hard disk accessible) 18 ; Floppy: 1 (Floppy disk, without change detection) 18 19 ; CX:DX: Total number of sectors 19 20 ; CF: 0 … … 25 26 ALIGN JUMP_ALIGN 26 27 AH15h_HandlerForReadDiskDriveSize: 28 %ifdef MODULE_SERIAL_FLOPPY 29 mov cl, 1 ; 1 = floppy disk, no change detection 30 31 test dl,dl ; DO NOT store the sector count if this is a 32 jns .FloppyDrive ; floppy disk, some OS's depend on this not 33 ; happening for floppies in order to boot. 34 %endif 35 27 36 call AH15h_GetSectorCountToBXDXAX 28 mov [bp+IDEPACK.intpack+INTPACK.cx], dx ; HIWORD to CX29 mov [bp+IDEPACK.intpack+INTPACK.dx], ax ; LOWORD to DX37 mov [bp+IDEPACK.intpack+INTPACK.cx], dx ; HIWORD to CX 38 xchg [bp+IDEPACK.intpack+INTPACK.dx], ax ; LOWORD to DX, AL gets drive number 30 39 31 xor ah, ah 32 call Int13h_SetErrorCodeToBdaAndToIntpackInSSBPfromAH ; Store success to BDA and CF 33 mov BYTE [bp+IDEPACK.intpack+INTPACK.ah], 3 ; Type code = Hard disk 40 xor ah, ah 41 %ifdef MODULE_SERIAL_FLOPPY 42 mov cl, 3 ; 3 = Hard Disk Accessible 43 .FloppyDrive: 44 45 call Int13h_SetErrorCodeToBdaAndToIntpackInSSBPfromAH_ALHasDriveNumber ; Store success to BDA and CF 46 mov BYTE [bp+IDEPACK.intpack+INTPACK.ah], cl 47 %else 48 call Int13h_SetErrorCodeToBdaAndToIntpackInSSBPfromAH ; Store success to BDA and CF 49 mov BYTE [bp+IDEPACK.intpack+INTPACK.ah], 3 50 %endif 51 34 52 jmp Int13h_ReturnFromHandlerWithoutStoringErrorCode 35 53 -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH1h_HStatus.asm
r150 r258 20 20 AH1h_HandlerForReadDiskStatus: 21 21 LOAD_BDA_SEGMENT_TO ds, ax, ! 22 23 %ifdef MODULE_SERIAL_FLOPPY 24 test dl, dl 25 jns .HardDisk 26 mov ah, [BDA.bFDRetST] ; Unlike for hard disks below, floppy version does not clear the status 27 jmp .done 28 .HardDisk: 29 %endif 30 22 31 xchg ah, [BDA.bHDLastSt] ; Load and clear last error 32 ; Note that AH is cleared with the LOAD_BDA_SEGMENT above 33 34 .done: 23 35 call Int13h_SetErrorCodeToIntpackInSSBPfromAH 24 36 jmp Int13h_ReturnFromHandlerWithoutStoringErrorCode -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH2h_HRead.asm
r249 r258 40 40 jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAHandTransferredSectorsFromCL 41 41 %endif 42 -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH8h_HParams.asm
r227 r258 14 14 ; SS:BP: Ptr to IDEPACK 15 15 ; Returns with INTPACK: 16 ; BL: Drive Type (for floppies only) 16 17 ; CH: Maximum cylinder number, bits 7...0 17 18 ; CL: Bits 7...6: Cylinder number bits 9...8 … … 19 20 ; DH: Maximum head number (0...255) 20 21 ; DL: Number of drives 22 ; ES:DI: Floppy DPT (for floppies only) 21 23 ; AH: Int 13h/40h floppy return status 22 24 ; CF: 0 if successfull, 1 if error 23 25 ;-------------------------------------------------------------------- 24 26 AH8h_HandlerForReadDiskDriveParameters: 27 25 28 call RamVars_IsDriveHandledByThisBIOS 26 jnc SHORT .GetDriveParametersForForeignHardDiskInDL 29 jnc SHORT .OurDrive 30 31 call Int13h_CallPreviousInt13hHandler 32 jnc SHORT .MidGame 33 jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH 34 35 .OurDrive: 27 36 call AH8h_GetDriveParameters 28 jmp SHORT .ReturnAfterStoringValuesToIntpack29 37 30 .GetDriveParametersForForeignHardDiskInDL: 31 call Int13h_CallPreviousInt13hHandler 32 jc SHORT .ReturnErrorFromPreviousInt13hHandler 33 call RamVars_GetCountOfKnownDrivesToDL 34 .ReturnAfterStoringValuesToIntpack: 38 %ifdef MODULE_SERIAL_FLOPPY 39 push cs ; setup registers if we are a floppy drive, in all cases 40 pop es ; if it is not a floppy drive, these values will not be put in INTPACK 41 mov di, AH8h_FloppyDPT 42 %endif 43 ;; fall-through 44 45 .MidGame: 46 call RamVars_GetCountOfKnownDrivesToAX ; assume hard disk for now, will discard if for floppies 47 48 test byte [bp+IDEPACK.intpack+INTPACK.dl], 080h 49 jnz .Done 50 51 mov [bp+IDEPACK.intpack+INTPACK.bl], bl 52 53 mov [bp+IDEPACK.intpack+INTPACK.es], es 54 mov [bp+IDEPACK.intpack+INTPACK.di], di 55 56 call FloppyDrive_GetCountToAX 57 58 .Done: 59 mov ah, dh 60 35 61 mov [bp+IDEPACK.intpack+INTPACK.cx], cx 36 mov [bp+IDEPACK.intpack+INTPACK.dx], dx 62 xchg [bp+IDEPACK.intpack+INTPACK.dx], ax ; recover DL for BDA last status byte determination 63 37 64 xor ah, ah 38 .ReturnErrorFromPreviousInt13hHandler: 65 %ifdef MODULE_SERIAL_FLOPPY 66 jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH_ALHasDriveNumber 67 %else 39 68 jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH 69 %endif 40 70 41 71 … … 51 81 ; Bits 5...0: Maximum sector number (1...63) 52 82 ; DH: Maximum head number (0...255) 53 ; DL: Number of drives54 83 ; Corrupts registers: 55 84 ; AX, BX … … 73 102 ; Bits 5...0: Maximum sector number (1...63) 74 103 ; DH: Maximum head number (0...255) 75 ; DL: Number of drives76 104 ; Corrupts registers: 77 105 ; AX, BX … … 85 113 or cl, bh ; CL bits 0...5 = Sectors per track 86 114 mov dh, bl ; DH = Maximum head number 87 jmp RamVars_GetCountOfKnownDrivesToDL 115 116 %ifdef MODULE_SERIAL_FLOPPY 117 mov bl,[di+DPT.bFlagsHigh] 118 eSHR_IM bl,FLGH_DPT_SERIAL_FLOPPY_TYPE_FIELD_POSITION 119 %endif 120 ret 121 122 %ifdef MODULE_SERIAL_FLOPPY 123 ; 124 ; Floppy Disk Parameter Table. There is no way to specify more than one of these 125 ; for any given system, so no way to make this drive or media specific. 126 ; So we return fixed values out of the ROM for callers might be expecting this information. 127 ; 128 ; On AT systems, we return the information for a 1.44 MB disk, 129 ; and on XT systems, we return the information for a 360 KB disk. 130 ; 131 AH8h_FloppyDPT: 132 %ifdef USE_AT 133 db 0ah << 4 | 0fh ; Offset 0: Drive timings, 1.44MB values 134 %else 135 db 0dh << 4 | 0fh ; Offset 0: Drive timings, 360KB values 136 %endif 137 138 db 1h << 1 | 0 ; Offset 1: Typical values of 1 for head load time 139 ; DMA used (although it actually is not, but is more restrctive) 140 db 25h ; Offset 2: Inactiviy motor turn-off delay, 141 ; Typical value of 25h for 2 second delay 142 db 02h ; Offset 3: Sector size, always 512 143 144 %ifdef USE_AT 145 db 12h ; Offset 4: Sectors per track, 1.44MB value 146 db 1bh ; Offset 5: Sector gap, 1.44MB value 147 %else 148 db 09h ; Offset 4: Sectors per track, 360KB value 149 db 2ah ; Offset 5: Sector gap, 360KB value 150 %endif 151 152 db 0ffh ; Offset 6: Data length 153 154 %ifdef USE_AT 155 db 6ch ; Offset 7: Format gap length, 1.44MB value 156 %else 157 db 50h ; Offset 7: Format gap length, 360KB value 158 %endif 159 160 db 0f6h ; Offset 8: Fill byte for format 161 db 0fh ; Offset 9: Head setting time 162 db 08h ; Offset A: Wait for motor startpu time 163 164 %ifdef USE_AT 165 db 79 ; Offset B: Maximum track number, 1.44MB value 166 db 0 ; Offset C: Data transfer rate, 1.44MB value 167 db 4 ; Offset D: Diskette CMOS drive type, 1.44MB value 168 %else 169 db 39 ; Offset B: Maximum track number, 360KB value 170 db 80h ; Offset C: Data transfer rate, 360KB value 171 db 1 ; Offset D: Diskette CMOS drive type, 360KB value 172 %endif 173 %endif -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm
r227 r258 43 43 push cx 44 44 45 %ifdef MODULE_SERIAL 46 ; 47 ; no need to do this for serial deveices, and we use the DPT_RESET flag bits 48 ; to store the drive type for serial floppy drives (MODULE_SERIAL_FLOPPY) 49 ; 50 xor ah, ah 51 test byte [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE ; Clears CF 52 jnz .ReturnNotSuccessfull 53 %endif 54 45 55 ; Try to select drive and wait until ready 46 56 or BYTE [di+DPT.bFlagsHigh], MASKH_DPT_RESET ; Everything uninitialized -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19h.asm
r250 r258 31 31 ; Install INT 19h handler for proper reboot 32 32 LOAD_BDA_SEGMENT_TO es, ax 33 mov bx, BIOS_BOOT_LOADER_INTERRUPT_19h ; INT 19h interrupt vector offset33 mov al, BIOS_BOOT_LOADER_INTERRUPT_19h ; INT 19h interrupt vector offset 34 34 mov si, Int19h_ResetHandler ; INT 19h handler to reboot the system 35 call Interrupts_InstallHandlerToVectorIn BXFromCSSI35 call Interrupts_InstallHandlerToVectorInALFromCSSI 36 36 call Initialize_AndDetectDrives ; Installs new boot menu loader 37 37 ; Fall to .PrepareStackAndSelectDriveFromBootMenu -
trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm
r254 r258 43 43 44 44 %ifdef MODULE_SERIAL 45 ;---------------------------------------------------------------------- 45 46 ; 46 47 ; if serial drive detected, do not scan (avoids duplicate drives and isn't needed - we already have a connection) … … 57 58 %endif 58 59 59 .done: 60 .done: 61 %ifdef MODULE_SERIAL_FLOPPY 62 ;---------------------------------------------------------------------- 63 ; 64 ; Add in any emulated serial floppy drives. 65 ; 66 mov al, [RAMVARS.xlateVars+XLATEVARS.bFlopCreateCnt] 67 dec al 68 mov cl, al 69 js .NoFloppies ; if no drives are present, we store 0ffh 70 71 call FloppyDrive_GetCountFromBIOS_or_BDA 72 73 push ax 74 75 add al, cl ; Add our drives to existing drive count 76 cmp al, 3 ; For BDA, max out at 4 drives (ours is zero based) 77 jl .MaxBDAFloppiesExceeded 78 mov al, 3 79 .MaxBDAFloppiesExceeded: 80 eROR_IM al, 2 ; move to bits 6-7 81 inc ax ; low order bit, indicating floppy drive exists 82 83 mov ah, [es:BDA.wEquipment] ; Load Equipment WORD low byte 84 and ah, 03eh ; Mask off drive number and drives present bit 85 or al, ah ; Or in new values 86 mov [es:BDA.wEquipment], al ; and store 87 88 mov al, 1eh ; BDA pointer to Floppy DPT 89 mov si, AH8h_FloppyDPT 90 call Interrupts_InstallHandlerToVectorInALFromCSSI 91 92 pop ax 93 94 shr cl, 1 ; number of drives, 1 or 2 only, to CF flag (clear=1, set=2) 95 rcl al, 1 ; starting drive number in upper 7 bits, number of drives in low bit 96 .NoFloppies: 97 mov [RAMVARS.xlateVars+XLATEVARS.bFlopCntAndFirst], al 98 %endif 99 60 100 ret 61 101 -
trunk/XTIDE_Universal_BIOS/Src/Initialization/FloppyDrive.asm
r181 r258 120 120 ; Returns number of Floppy Drives in system. 121 121 ; 122 ; FloppyDrive_GetCountToCX 123 ; Parameters: 124 ; Nothing 125 ; Returns: 126 ; CX: Number of Floppy Drives 127 ; Corrupts registers: 128 ; Nothing 129 ;-------------------------------------------------------------------- 130 ALIGN JUMP_ALIGN 131 FloppyDrive_GetCountToCX: 122 ; FloppyDrive_GetCountToAX 123 ; Parameters: 124 ; DS: RAMVARS Segment 125 ; Returns: 126 ; AX: Number of Floppy Drives 127 ;-------------------------------------------------------------------- 128 ALIGN JUMP_ALIGN 129 FloppyDrive_GetCountToAX: 130 %ifdef MODULE_SERIAL_FLOPPY 131 call RamVars_UnpackFlopCntAndFirstToAL 132 adc al,1 ; adds in the drive count bit, and adds 1 for count vs. 0-index, 133 ; but still won't impact SF 134 jns .UseInternalNumber ; need to clear CH on the way out, and add in additional drive numbers 135 136 %endif 137 call FloppyDrive_GetCountFromBIOS_or_BDA 138 139 .UseInternalNumber: 140 mov ah, [cs:ROMVARS.bMinFddCnt] 141 MAX_U al, ah 142 cbw 143 144 ret 145 146 ALIGN JUMP_ALIGN 147 FloppyDrive_GetCountFromBIOS_or_BDA: 132 148 push es 133 %ifdef USE_AT134 call GetCountFromBIOS135 %else136 call GetCountFromBDA137 %endif138 mov ch, [cs:ROMVARS.bMinFddCnt]139 MAX_U cl, ch140 pop es141 xor ch, ch142 ret143 144 149 145 150 ;-------------------------------------------------------------------- … … 160 165 %ifdef USE_AT 161 166 ALIGN JUMP_ALIGN 162 GetCountFromBIOS:167 .GetCountFromBIOS: 163 168 push di 164 169 push dx 165 170 push bx 166 push ax167 171 168 172 mov ah, 08h ; Get Drive Parameters 169 173 cwd ; Floppy Drive 00h 170 174 int BIOS_DISKETTE_INTERRUPT_40h 171 mov cl, dl ; Number of Floppy Drives to CL 172 173 pop ax 175 mov al, dl ; Number of Floppy Drives to AL 176 174 177 pop bx 175 178 pop dx 176 179 pop di 177 ret 178 %endif 179 180 %endif 180 181 181 182 ;-------------------------------------------------------------------- … … 193 194 %ifndef USE_AT 194 195 ALIGN JUMP_ALIGN 195 GetCountFromBDA: 196 LOAD_BDA_SEGMENT_TO es, cx 197 mov cl, [es:BDA.wEquipment] ; Load Equipment WORD low byte 198 mov ch, cl ; Copy it to CH 199 and cx, 0C001h ; Leave bits 15..14 and 0 200 eROL_IM ch, 2 ; EW low byte bits 7..6 to 1..0 201 add cl, ch ; CL = Floppy Drive count 202 ret 203 %endif 196 .GetCountFromBDA: 197 LOAD_BDA_SEGMENT_TO es, ax 198 mov al, [es:BDA.wEquipment] ; Load Equipment WORD low byte 199 mov ah, al ; Copy it to CH 200 and ax, 0C001h ; Leave bits 15..14 and 0 201 eROL_IM ah, 2 ; EW low byte bits 7..6 to 1..0 202 add al, ah ; CL = Floppy Drive count 203 %endif 204 205 pop es 206 ret 207 -
trunk/XTIDE_Universal_BIOS/Src/Initialization/Initialize.asm
r243 r258 29 29 30 30 ; Install INT 19h handler (boot loader) where drives are detected 31 mov bx, BIOS_BOOT_LOADER_INTERRUPT_19h31 mov al, BIOS_BOOT_LOADER_INTERRUPT_19h 32 32 mov si, Int19h_BootLoaderHandler 33 call Interrupts_InstallHandlerToVectorIn BXFromCSSI33 call Interrupts_InstallHandlerToVectorInALFromCSSI 34 34 35 35 .SkipRomInitialization: … … 73 73 mov dl, 80h 74 74 call RamVars_IsDriveHandledByThisBIOS 75 j nc SHORT .FindForDrive81h ; Store nothing if not our drive75 jc SHORT .FindForDrive81h ; Store nothing if not our drive 76 76 call FindDPT_ForDriveNumber ; DPT to DS:DI 77 77 mov [es:HD0_DPT_POINTER_41h*4], di … … 80 80 inc dx 81 81 call RamVars_IsDriveHandledByThisBIOS 82 j nc SHORT .ResetDetectedDrives82 jc SHORT .ResetDetectedDrives 83 83 call FindDPT_ForDriveNumber 84 84 mov [es:HD1_DPT_POINTER_46h*4], di -
trunk/XTIDE_Universal_BIOS/Src/Initialization/Interrupts.asm
r243 r258 34 34 mov ax, [es:BIOS_DISK_INTERRUPT_13h*4] ; Load old INT 13h offset 35 35 mov [RAMVARS.fpOldI13h], ax ; Store old INT 13h offset 36 37 mov bx, BIOS_DISK_INTERRUPT_13h ; INT 13h interrupt vector offset38 mov si, Int13h_DiskFunctionsHandler ; Interrupt handler offset39 call Interrupts_InstallHandlerToVectorInBXFromCSSI40 36 41 37 ; Only store INT 13h handler to 40h if 40h is not already installed. … … 47 43 mov [es:BIOS_DISKETTE_INTERRUPT_40h*4+2], dx ; Store old INT 13h segment 48 44 .Int40hAlreadyInstalled: 45 46 mov al, BIOS_DISK_INTERRUPT_13h ; INT 13h interrupt vector offset 47 mov si, Int13h_DiskFunctionsHandler ; Interrupt handler offset 48 call Interrupts_InstallHandlerToVectorInALFromCSSI 49 49 ; Fall to .InitializeHardwareIrqHandlers 50 50 … … 56 56 ; Nothing 57 57 ; Corrupts registers: 58 ; BX, CX, DX, SI, DI 58 ; BX, CX, DX, SI, DI, AX 59 59 ;-------------------------------------------------------------------- 60 60 .InitializeHardwareIrqHandlers: … … 62 62 mov di, ROMVARS.ideVars0 ; CS:SI points to first IDEVARS 63 63 .IdeControllerLoop: 64 eMOVZX bx, BYTE [cs:di+IDEVARS.bIRQ]64 mov al, BYTE [cs:di+IDEVARS.bIRQ] 65 65 add di, BYTE IDEVARS_size ; Increment to next controller 66 66 call .InstallLowOrHighIrqHandler … … 72 72 ; .InstallLowOrHighIrqHandler 73 73 ; Parameters: 74 ; BX: IRQ number, 0 if IRQ disabled74 ; AL: IRQ number, 0 if IRQ disabled 75 75 ; ES: BDA and Interrupt Vector segment (zero) 76 76 ; Returns: … … 80 80 ;-------------------------------------------------------------------- 81 81 .InstallLowOrHighIrqHandler: 82 test bl, bl82 test al, al 83 83 jz SHORT .Return ; IRQ not used 84 cmp bl, 884 cmp al, 8 85 85 jb SHORT .InstallLowIrqHandler 86 86 ; Fall to .InstallHighIrqHandler … … 94 94 ; Nothing 95 95 ; Corrupts registers: 96 ; BX, SI96 ; AL, BX, SI 97 97 ;-------------------------------------------------------------------- 98 98 .InstallHighIrqHandler: 99 add bx, BYTE HARDWARE_IRQ_8_INTERRUPT_70h - 8 ; Interrupt vector number99 add al, BYTE HARDWARE_IRQ_8_INTERRUPT_70h - 8 ; Interrupt vector number 100 100 mov si, IdeIrq_InterruptServiceRoutineForIrqs8to15 101 jmp SHORT Interrupts_InstallHandlerToVectorIn BXFromCSSI101 jmp SHORT Interrupts_InstallHandlerToVectorInALFromCSSI 102 102 103 103 ;-------------------------------------------------------------------- 104 104 ; .InstallLowIrqHandler 105 105 ; Parameters: 106 ; BX: IRQ number (0...7)107 ; ES: BDA and Interrupt Vector segment (zero) 108 ; Returns: 109 ; Nothing 110 ; Corrupts registers: 111 ; BX, SI106 ; AL: IRQ number (0...7) 107 ; ES: BDA and Interrupt Vector segment (zero) 108 ; Returns: 109 ; Nothing 110 ; Corrupts registers: 111 ; AL, BX, SI 112 112 ;-------------------------------------------------------------------- 113 113 .InstallLowIrqHandler: 114 add bx, BYTE HARDWARE_IRQ_0_INTERRUPT_08h ; Interrupt vector number114 add al, BYTE HARDWARE_IRQ_0_INTERRUPT_08h ; Interrupt vector number 115 115 mov si, IdeIrq_InterruptServiceRoutineForIrqs2to7 116 ; Fall to Interrupts_InstallHandlerToVectorIn BXFromCSSI117 118 119 ;-------------------------------------------------------------------- 120 ; Interrupts_InstallHandlerToVectorIn BXFromCSSI121 ; Parameters: 122 ; BX: Interrupt vector number (for example 13h)116 ; Fall to Interrupts_InstallHandlerToVectorInALFromCSSI 117 118 119 ;-------------------------------------------------------------------- 120 ; Interrupts_InstallHandlerToVectorInALFromCSSI 121 ; Parameters: 122 ; AL: Interrupt vector number (for example 13h) 123 123 ; ES: BDA and Interrupt Vector segment (zero) 124 124 ; CS:SI: Ptr to interrupt handler … … 126 126 ; Nothing 127 127 ; Corrupts registers: 128 ; BX 129 ;-------------------------------------------------------------------- 130 Interrupts_InstallHandlerToVectorInBXFromCSSI: 131 eSHL_IM bx, 2 ; Shift for DWORD offset 128 ; AX, BX 129 ;-------------------------------------------------------------------- 130 Interrupts_InstallHandlerToVectorInALFromCSSI: 131 mov bl, 4 ; Shift for DWORD offset, MUL smaller than other alternatives 132 mul bl 133 xchg ax, bx 132 134 mov [es:bx], si ; Store offset 133 135 mov [es:bx+2], cs ; Store segment -
trunk/XTIDE_Universal_BIOS/Src/Main.asm
r254 r258 176 176 %include "BootMenuEvent.asm" ; For menu library event handling 177 177 ; NOTE: BootMenuPrint needs to come immediately after BootMenuEvent 178 %include "BootMenuPrint.asm" ; For printing Boot Menu strings 178 ; so that jump table entries in BootMenuEvent stay within 8-bits 179 %include "BootMenuPrint.asm" ; For printing Boot Menu strings, also includes "BootMenuPrintCfg.asm" 179 180 %include "BootPrint.asm" ; For printing boot information 180 %include "BootMenuPrintCfg.asm" ; For printing hard disk configuration181 181 %include "FloppyDrive.asm" ; Floppy Drive related functions 182 182 %include "BootSector.asm" ; For loading boot sector -
trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm
r227 r258 63 63 .StoreFlags: 64 64 mov [di+DPT.wFlags], ax 65 66 %ifdef MODULE_SERIAL67 cmp byte [cs:bp+IDEVARS.bDevice], DEVICE_SERIAL_PORT68 jnz .StoreAddressing69 or byte [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE70 %endif71 65 ; Fall to .StoreAddressing 72 66 … … 205 199 .StoreDeviceSpecificParameters: 206 200 call Device_FinalizeDPT 201 202 %ifdef MODULE_SERIAL_FLOPPY 203 ; 204 ; These two instructions serve two purposes: 205 ; 1. If the drive is a floppy drive (CF set), then we effectively increment the counter. 206 ; 2. If this is a hard disk, and there have been any floppy drives previously added, then the hard disk is 207 ; effectively discarded. This is more of a safety check then code that should ever normally be hit (see below). 208 ; Since the floppy DPT's come after the hard disk DPT's, without expensive (code size) code to relocate a DPT, 209 ; this was necessary. Now, this situation shouldn't happen in normal operation, for a couple of reasons: 210 ; A. xtidecfg always puts configured serial ports at the end fo the IDEVARS list 211 ; B. the auto serial code is always executed last 212 ; C. the serial server always returns floppy drives last 213 ; 214 adc byte [RAMVARS.xlateVars+XLATEVARS.bFlopCreateCnt], 0 215 jnz .AllDone 216 %else 217 ; 218 ; Even without floppy support enabled, we shouldn't try to mount a floppy image as a hard disk, which 219 ; could lead to unpredictable results since no MBR will be present, etc. The server doesn't know that 220 ; floppies are supported, so it is important to still fail here if a floppy is seen during the drive scan. 221 ; 222 jc .AllDone 223 %endif 224 207 225 ; Fall to .StoreDriveNumberAndUpdateDriveCount 208 226 … … 230 248 ja SHORT .AllDone ; If so, return 231 249 mov [RAMVARS.bFirstDrv], dl ; Store first drive number 250 251 .AllDone: 232 252 clc 233 .AllDone:234 253 ret 254 -
trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/FindDPT.asm
r233 r258 14 14 ; DS:DI: Ptr to first unused DPT 15 15 ; Corrupts registers: 16 ; D L16 ; DX 17 17 ;-------------------------------------------------------------------- 18 18 ALIGN JUMP_ALIGN 19 19 FindDPT_ForNewDriveToDSDI: 20 mov dl, [RAMVARS.bFirstDrv] 21 add dl, [RAMVARS.bDrvCnt] 20 mov ax, [RAMVARS.wDrvCntAndFirst] 21 add al, ah 22 %ifdef MODULE_SERIAL_FLOPPY 23 add al, [RAMVARS.xlateVars+XLATEVARS.bFlopCreateCnt] 24 %endif 25 xchg ax, dx 22 26 ; Fall to FindDPT_ForDriveNumber 23 27 … … 41 45 xchg di, ax ; Save the contents of AX in DI 42 46 47 %ifdef MODULE_SERIAL_FLOPPY 48 mov ax, [RAMVARS.wDrvCntAndFirst] 49 50 test dl, dl 51 js .harddisk 52 53 call RamVars_UnpackFlopCntAndFirstToAL 54 add dl, ah ; add in end of hard disk DPT list, floppies start immediately after 55 .harddisk: 56 sub dl, al ; subtract off beginning of either hard disk or floppy list (as appropriate) 57 %else 58 sub dl, [RAMVARS.bFirstDrv] ; subtract off beginning of hard disk list 59 %endif 60 43 61 mov al, LARGEST_DPT_SIZE 44 sub dl, [RAMVARS.bFirstDrv]62 45 63 mul dl 46 64 add ax, BYTE RAMVARS_size 47 65 48 xchg di, ax ; Restore AX and put result in DI66 xchg di, ax ; Restore AX and put result in DI 49 67 pop dx 50 68 ret … … 89 107 ; IterateToMasterAtPortCallback 90 108 ; Parameters: 91 ; CH: Drive number92 109 ; DX: IDE Base Port address 93 110 ; DS:DI: Ptr to DPT to examine 94 111 ; Returns: 95 ; DL: Drive number if correct DPT96 112 ; CF: Set if wanted DPT found 97 113 ; Cleared if wrong DPT … … 116 132 pop bx 117 133 jne SHORT ReturnWrongDPT 118 mov dl, ch ; Return drive number in DL119 134 120 135 ReturnRightDPT: … … 187 202 ; Returns: 188 203 ; DS:DI: Ptr to wanted DPT (if found) 204 ; If not found, points to first empty DPT 189 205 ; CF: Set if wanted DPT found 190 206 ; Cleared if DPT not found, or no DPTs present … … 195 211 IterateAllDPTs: 196 212 push cx 197 mov cx, [RAMVARS.wDrvCntAndFirst] 213 214 mov cl, [RAMVARS.bDrvCnt] 215 mov ch, 0 216 217 mov di, RAMVARS_size ; Point DS:DI to first DPT 218 198 219 jcxz .NotFound ; Return if no drives 199 mov di, RAMVARS_size ; Point DS:DI to first DPT220 200 221 ALIGN JUMP_ALIGN 201 222 .LoopWhileDPTsLeft: 202 223 call si ; Is wanted DPT? 203 224 jc SHORT .AllDptsIterated ; If so, return 204 inc ch ; Increment drive number205 225 add di, BYTE LARGEST_DPT_SIZE ; Point to next DPT 206 dec cl ; Decrement drives left207 jnz SHORT .LoopWhileDPTsLeft226 loop .LoopWhileDPTsLeft 227 208 228 .NotFound: 209 229 clc ; Clear CF since DPT not found 230 210 231 ALIGN JUMP_ALIGN 211 232 .AllDptsIterated: -
trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/RamVars.asm
r241 r258 123 123 ; DS: RAMVARS segment 124 124 ; Returns: 125 ; CF: Setif function is handled by this BIOS126 ; Clearedif function belongs to some other BIOS125 ; CF: Cleared if function is handled by this BIOS 126 ; Set if function belongs to some other BIOS 127 127 ; Corrupts registers: 128 128 ; Nothing … … 131 131 RamVars_IsFunctionHandledByThisBIOS: 132 132 test ah, ah ; Reset for all floppy and hard disk drives? 133 jz SHORT .FunctionIsHandledByOurBIOS134 cmp ah, 08h ; Read Disk Drive Parameters?135 jne SHORT RamVars_IsDriveHandledByThisBIOS 136 test dl, dl ; We do not handle floppy drives137 j ns SHORT .FunctionIsNotHandledByOurBIOS138 ALIGN JUMP_ALIGN 139 .FunctionIsHandledByOurBIOS: 140 stc141 .FunctionIsNotHandledByOurBIOS: 142 ret 143 133 jz SHORT RamVars_IsDriveHandledByThisBIOS.CFAlreadyClear_IsHandledByOurBIOS 134 cmp ah, 08h 135 %ifdef MODULE_SERIAL_FLOPPY 136 ; we handle all traffic for function 08h, as we need to wrap both hard disk and floppy drive counts 137 je SHORT RamVars_IsDriveHandledByThisBIOS.CFAlreadyClear_IsHandledByOurBIOS 138 %else 139 ; we handle all *hard disk* traffic for function 08h, as we need to wrap the hard disk drive count 140 je SHORT RamVars_IsDriveHandledByThisBIOS.IsDriveAHardDisk 141 %endif 142 ;;; fall-through 143 144 144 ;-------------------------------------------------------------------- 145 145 ; Checks if drive is handled by this BIOS. … … 150 150 ; DS: RAMVARS segment 151 151 ; Returns: 152 ; CF: Setif drive is handled by this BIOS153 ; Clearedif drive belongs to some other BIOS152 ; CF: Cleared if drive is handled by this BIOS 153 ; Set if drive belongs to some other BIOS 154 154 ; Corrupts registers: 155 155 ; Nothing … … 158 158 RamVars_IsDriveHandledByThisBIOS: 159 159 push ax 160 mov ax, [RAMVARS.wDrvCntAndFirst] ; Drive count to AL, First number to AH 161 add al, ah ; One past last drive to AL 162 cmp dl, al ; Above last supported? 163 jae SHORT .DriveNotHandledByThisBIOS 164 cmp ah, dl ; Below first supported? 165 ja SHORT .DriveNotHandledByThisBIOS 166 stc 167 .DriveNotHandledByThisBIOS: 160 161 mov ax, [RAMVARS.wDrvCntAndFirst] ; Drive count to AH, First number to AL 162 add ah, al ; One past last drive to AH 163 cmp dl, ah ; Above last supported? 164 jae SHORT .HardDiskIsNotHandledByThisBIOS 165 .TestLowLimit: 166 cmp dl, al ; Below first supported? 167 jae SHORT .CFAlreadyClear_IsHandledByOurBIOS_PopAX ; note that CF is clear if the branch is taken 168 169 .HardDiskIsNotHandledByThisBIOS: 170 %ifdef MODULE_SERIAL_FLOPPY 171 call RamVars_UnpackFlopCntAndFirstToAL 172 cbw ; normally 0h, could be ffh if no drives present 173 adc ah, al ; if no drives present, still ffh (ffh + ffh + 1 = ffh) 174 js SHORT .DiskIsNotHandledByThisBIOS 175 cmp ah, dl 176 jz SHORT .CFAlreadyClear_IsHandledByOurBIOS_PopAX 177 cmp al, dl 178 jz SHORT .CFAlreadyClear_IsHandledByOurBIOS_PopAX 179 .DiskIsNotHandledByThisBIOS: 180 %endif 181 182 stc ; Is not supported by our BIOS 183 184 .CFAlreadyClear_IsHandledByOurBIOS_PopAX: 168 185 pop ax 169 ret 170 171 172 ;-------------------------------------------------------------------- 173 ; RamVars_GetHardDiskCountFromBDAtoCX 174 ; Parameters: 175 ; DS: RAMVARS segment 176 ; Returns: 177 ; CX: Total hard disk count 178 ; Corrupts registers: 179 ; Nothing 180 ;-------------------------------------------------------------------- 181 ALIGN JUMP_ALIGN 182 RamVars_GetHardDiskCountFromBDAtoCX: 186 .CFAlreadyClear_IsHandledByOurBIOS: 187 ret 188 189 %ifndef MODULE_SERIAL_FLOPPY 190 ; 191 ; Note that we could have just checked for the high order bit in dl, but with the needed STC and jumps, 192 ; leveraging the code above resulted in space savings. 193 ; 194 .IsDriveAHardDisk: 195 push ax ; match stack at the top of routine 196 mov al, 80h ; to catch all hard disks, lower limit is 80h vs. bFirstDrv 197 jmp .TestLowLimit ; and there is no need to test a high limit 198 %endif 199 200 ;-------------------------------------------------------------------- 201 ; RamVars_GetHardDiskCountFromBDAtoAX 202 ; Parameters: 203 ; DS: RAMVARS segment 204 ; Returns: 205 ; AX: Total hard disk count 206 ; Corrupts registers: 207 ; CX 208 ;-------------------------------------------------------------------- 209 ALIGN JUMP_ALIGN 210 RamVars_GetHardDiskCountFromBDAtoAX: 183 211 push es 184 push dx 185 186 LOAD_BDA_SEGMENT_TO es, cx, ! ; Zero CX 187 call RamVars_GetCountOfKnownDrivesToDL 212 213 LOAD_BDA_SEGMENT_TO es, ax 214 call RamVars_GetCountOfKnownDrivesToAX 188 215 mov cl, [es:BDA.bHDCount] 189 MAX_U cl, dl 190 191 pop dx 216 MAX_U al, cl 217 192 218 pop es 193 219 ret 194 220 195 221 ;-------------------------------------------------------------------- 196 ; RamVars_GetCountOfKnownDrivesTo DL197 ; Parameters: 198 ; DS: RAMVARS segment 199 ; Returns: 200 ; DL: Total hard disk count201 ; Corrupts registers: 202 ; No thing203 ;-------------------------------------------------------------------- 204 ALIGN JUMP_ALIGN 205 RamVars_GetCountOfKnownDrivesTo DL:206 mov dl, [RAMVARS.bFirstDrv] ; Number for our first drive207 add dl, [RAMVARS.bDrvCnt] ; Our drives208 and dl, 7Fh ; Clear HD bit for drive count209 ret210 211 222 ; RamVars_GetCountOfKnownDrivesToAX 223 ; Parameters: 224 ; DS: RAMVARS segment 225 ; Returns: 226 ; AX: Total hard disk count 227 ; Corrupts registers: 228 ; None 229 ;-------------------------------------------------------------------- 230 ALIGN JUMP_ALIGN 231 RamVars_GetCountOfKnownDrivesToAX: 232 mov ax, [RAMVARS.wDrvCntAndFirst] 233 add al, ah 234 and al, 7fh 235 cbw 236 ret 237 212 238 ;-------------------------------------------------------------------- 213 239 ; RamVars_GetIdeControllerCountToCX … … 219 245 ; Nothing 220 246 ;-------------------------------------------------------------------- 247 ALIGN JUMP_ALIGN 221 248 RamVars_GetIdeControllerCountToCX: 222 249 eMOVZX cx, BYTE [cs:ROMVARS.bIdeCnt] 223 250 ret 251 252 %ifdef MODULE_SERIAL_FLOPPY 253 ;-------------------------------------------------------------------- 254 ; RamVars_UnpackFlopCntAndFirstToAL 255 ; Parameters: 256 ; Nothing 257 ; Returns: 258 ; AL: First floppy drive number supported 259 ; CF: Number of floppy drives supported (clear = 1, set = 2) 260 ; Corrupts registers: 261 ; Nothing 262 ;-------------------------------------------------------------------- 263 ALIGN JUMP_ALIGN 264 RamVars_UnpackFlopCntAndFirstToAL: 265 mov al, [RAMVARS.xlateVars+XLATEVARS.bFlopCntAndFirst] 266 sar al, 1 267 ret 268 %endif -
trunk/XTIDE_Universal_BIOS/makefile
r252 r258 66 66 # Assembler preprocessor defines. # 67 67 ################################################################# 68 DEFINES = INCLUDE_MENU_LIBRARY EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS MODULE_EBIOS MODULE_SERIAL MODULE_STRINGS_COMPRESSED 68 DEFINES = INCLUDE_MENU_LIBRARY EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS MODULE_EBIOS MODULE_SERIAL MODULE_STRINGS_COMPRESSED MODULE_SERIAL_FLOPPY 69 69 DEFINES_XT = ELIMINATE_CGA_SNOW 70 70 DEFINES_XTPLUS = ELIMINATE_CGA_SNOW USE_186 -
trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/ConfigurationMenu.asm
r206 r258 276 276 CALL_MENU_LIBRARY RefreshItemFromAX 277 277 pop es 278 ret 278 ; Fall to ConfigurationMenu_CheckAndMoveSerialDrivesToBottom 279 280 ;---------------------------------------------------------------------- 281 ; ConfigurationMenu_CheckAndMoveSerialDrivesToBottom 282 ; 283 ; Checks to ensure that serial adapters are at the end of the 284 ; IDEVARS structures list, as serial floppies (if present) need to be 285 ; the last drives detected by the BIOS. If there are other controllers 286 ; after a serial controller, the other controllers are moved up on the list 287 ; and the serial controller is placed at the end of the list. 288 ; 289 ; Parameters: 290 ; SS:BP: Menu handle 291 ; Returns: 292 ; Nothing 293 ; Corrupts registers: 294 ; All 295 ;---------------------------------------------------------------------- 296 ConfigurationMenu_CheckAndMoveSerialDrivesToBottom: 297 push es 298 push ds 299 push di 300 push si 301 302 call Buffers_GetIdeControllerCountToCX ; will also set ES:DI to point to file buffer 303 push es 304 pop ds 305 mov ch, 0 ; clearing high order of CX and notification flag 306 mov dx, cx ; (probably unncessary, CX should be less than 127, but just to be sure) 307 jcxz .done ; probably unnecessary, but make sure there is at least one controller 308 309 add di, ROMVARS.ideVars0 ; add in offset of first idevars 310 mov bx, di 311 312 .outerLoop: 313 mov di, bx ; start of idevars 314 xor si, si ; first serial found 315 xor ax, ax ; first non-serial found 316 mov cl, dl ; idevars count 317 mov ch, 0 318 319 .loop: 320 cmp byte [di+IDEVARS.bDevice], DEVICE_SERIAL_PORT 321 jnz .notSerial 322 323 test si, si ; record the first serial controllert that we find 324 jnz .next 325 mov si, di 326 jmp .next 327 328 .notSerial: 329 mov ax, di ; record the *last* non-serial controller that we find 330 331 .next: 332 add di, IDEVARS_size 333 loop .loop 334 335 test si,si ; no serial drives, nothing to do 336 jz .done 337 cmp si,ax ; serial port is already later on the list than any other controllers 338 ja .done ; (also takes care of the case where ther are no other controllers) 339 340 ; 341 ; move serial to end of list, others up 342 ; 343 cld 344 345 mov ax, di ; save end pointer of list after scan 346 347 sub sp, IDEVARS_size ; copy serial to temporary space on stack 348 349 mov di, sp 350 351 mov cx, IDEVARS_size 352 push ss 353 pop es 354 355 rep movsb 356 357 mov di, si ; move up all the idevars below the serial, by one slot 358 sub di, IDEVARS_size 359 360 mov cx, ax ; restore end pointer of list, subtract off end of serial idevars 361 sub cx, si 362 363 push ds 364 pop es 365 366 rep movsb 367 368 mov si, sp ; place serial (currently on the stack) at bottom of list 369 push ss 370 pop ds 371 mov cx, IDEVARS_size 372 ; di is already at last IDEVARS position 373 374 rep movsb 375 376 add sp, IDEVARS_size 377 378 push es 379 pop ds 380 381 mov dh, 1 ; set flag that we have done a relocation 382 383 jmp .outerLoop 384 385 .done: 386 pop si 387 pop di 388 pop ds 389 pop es 390 391 test dh, dh 392 jz .noWorkDone 393 394 mov dx, g_szSerialMoved 395 call Dialogs_DisplayNotificationFromCSDX 396 397 .noWorkDone: 398 ret -
trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Strings.asm
r242 r258 97 97 g_szNfoCfgIdeCnt: db "Number of IDE controllers to manage.",NULL 98 98 99 g_szSerialMoved: db "A Serial Controller has been moved to the end of the Controller list. No further action is required. Serial Controllers must be placed at the end of the list.",NULL 100 99 101 g_szHelpCfgFullMode: incbin "Configuration_FullMode.txt" 100 102 db NULL 101 103 g_szHelpCfgStealSize: incbin "Configuration_StealSize.txt" 102 104 db NULL 103 104 105 105 106 ; Strings for IDE Controller menu
Note:
See TracChangeset
for help on using the changeset viewer.