Changeset 526 in xtideuniversalbios for trunk/Serial_Server/library
- Timestamp:
- Mar 15, 2013, 1:38:58 AM (12 years ago)
- google:author:
- krille_n_@hotmail.com
- Location:
- trunk/Serial_Server/library
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Serial_Server/library/Checksum.cpp
r376 r526 6 6 7 7 // 8 // XTIDE Universal BIOS and Associated Tools 9 // Copyright (C) 2009-2010 by Tomi Tilli, 2011-201 2by XTIDE Universal BIOS Team.8 // XTIDE Universal BIOS and Associated Tools 9 // Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team. 10 10 // 11 11 // This program is free software; you can redistribute it and/or modify … … 13 13 // the Free Software Foundation; either version 2 of the License, or 14 14 // (at your option) any later version. 15 // 15 // 16 16 // This program is distributed in the hope that it will be useful, 17 17 // but WITHOUT ANY WARRANTY; without even the implied warranty of 18 18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 // GNU General Public License for more details. 19 // GNU General Public License for more details. 20 20 // Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 21 21 // 22 22 23 23 // 24 // This file implements Fletcher's Checksum. The serial code uses this checksum, as it is very quick 24 // This file implements Fletcher's Checksum. The serial code uses this checksum, as it is very quick 25 25 // to calculate in assembly and offers reasonable error detection. 26 26 // For more information, see http://en.wikipedia.org/wiki/Fletcher%27s_checksum. 27 27 // 28 // Since it is faster in 8088 assembly code to deal with 16-bit quantities than 8-bit quantities, 28 // Since it is faster in 8088 assembly code to deal with 16-bit quantities than 8-bit quantities, 29 29 // Fletcher's Checksum has been modified to calculate the 32-bit checksum, and then "fold" the result into a 30 // 16-bit quantity. Fletcher's 32-bit Checksum consists of two parts: concatenated 16-bit accumulators. 31 // To "fold" to 16-bits, The upper and lower 8-bits of each of these accumulators is XOR'd independently, and then 30 // 16-bit quantity. Fletcher's 32-bit Checksum consists of two parts: concatenated 16-bit accumulators. 31 // To "fold" to 16-bits, The upper and lower 8-bits of each of these accumulators is XOR'd independently, and then 32 32 // the two results concatenated together, resulting in 16-bits. Although simpler, an early attempt to XOR the 33 33 // 16-bit accumulators results in poorer error detection behavior. Folding as described here results in error … … 35 35 // 36 36 // With #define CHECKSUM_TEST, this file becomes a self-contained command line program that runs 37 // some statistical tests comparing various checksum algorithms with random 512-byte sectors and various 37 // some statistical tests comparing various checksum algorithms with random 512-byte sectors and various 38 38 // levels of errors introduced. 39 39 // … … 58 58 b = (b & 0xffff) + (b >> 16); 59 59 60 // Although tempting to use, for its simplicity and size/speed in assembly, the following folding 60 // Although tempting to use, for its simplicity and size/speed in assembly, the following folding 61 61 // algorithm results in many undetected single bit errors and therefore should not be used. 62 62 // return( (unsigned short) (a ^ b) ); … … 68 68 69 69 //==================================================================================================== 70 // 70 // 71 71 // Test Code 72 72 // … … 82 82 unsigned char bit[] = { 1, 2, 4, 8, 16, 32, 64, 128 }; 83 83 84 class algorithm 84 class algorithm 85 85 { 86 86 public: … … 113 113 114 114 //---------------------------------------------------------------------------------------------------- 115 // 115 // 116 116 // Standard CRC-16 117 117 // … … 131 131 unsigned short j; 132 132 133 for(i = 0; i < 256; ++i) 133 for(i = 0; i < 256; ++i) 134 134 { 135 135 value = 0; … … 147 147 } 148 148 149 unsigned short checksum( unsigned char *data, int len ); 149 unsigned short checksum( unsigned char *data, int len ); 150 150 151 151 private: … … 158 158 int i; 159 159 160 for(i = 0; i < len; ++i) 160 for(i = 0; i < len; ++i) 161 161 { 162 162 unsigned char index = (unsigned char)(crc ^ data[i]); … … 168 168 169 169 //---------------------------------------------------------------------------------------------------- 170 // 170 // 171 171 // Basic checksum (just add up the bytes) 172 172 // … … 175 175 { 176 176 public: 177 unsigned short checksum( unsigned char *data, int len ); 177 unsigned short checksum( unsigned char *data, int len ); 178 178 basic_algorithm( algorithm *last ) : algorithm( last, (char *) "basic" ) { }; 179 179 }; … … 193 193 { 194 194 public: 195 unsigned short checksum( unsigned char *data, int len ); 195 unsigned short checksum( unsigned char *data, int len ); 196 196 fletcher16_algorithm( algorithm *last ) : algorithm( last, (char *) "f-16" ) { } 197 197 }; … … 213 213 214 214 //---------------------------------------------------------------------------------------------------- 215 // 215 // 216 216 // Folded Fletcher's Checksum (what we use in the serial code, from the top of this file) 217 217 // … … 220 220 { 221 221 public: 222 unsigned short checksum( unsigned char *data, int len ); 222 unsigned short checksum( unsigned char *data, int len ); 223 223 folded_fletcher32_algorithm( algorithm *last ) : algorithm( last, (char *) "fold-f-32" ) { } 224 224 }; … … 230 230 231 231 //---------------------------------------------------------------------------------------------------- 232 // 232 // 233 233 // Test Driver and Support routines 234 234 // … … 283 283 { 284 284 a->found = (unsigned long *) calloc( BUCKETS, sizeof(long) ); 285 285 286 286 a->zero = (unsigned long) a->checksum( bbuff, BBUFF_LENGTH ); 287 287 288 288 a->min = iterations+1; 289 289 } 290 290 291 291 printf( "\n" ); 292 292 PRINTROW( "zero ", "%10d ", a->zero ); … … 344 344 345 345 bbuff[ rand() % 512 ] ^= bit[ rand() % 8 ]; 346 346 347 347 if( b > 0 ) 348 348 { … … 354 354 } 355 355 } 356 } 356 } 357 357 358 358 printf( "\nbit change test:\n" ); -
trunk/Serial_Server/library/File.h
r376 r526 6 6 // 7 7 // Routines for accessing the file system using generic routines, which 8 // should work on all systems. The issue with using these is that 8 // should work on all systems. The issue with using these is that 9 9 // ftell() and fseek() are limited to 2 GB files (signed 32-bit quantities) 10 // and there is no standard for 64-bit quantities. So, look for a 11 // OS specific version of this file in the distribution, such as 10 // and there is no standard for 64-bit quantities. So, look for a 11 // OS specific version of this file in the distribution, such as 12 12 // win32/win32file.h which may be in use instead. 13 // 13 // 14 14 15 15 // 16 // XTIDE Universal BIOS and Associated Tools 17 // Copyright (C) 2009-2010 by Tomi Tilli, 2011-201 2by XTIDE Universal BIOS Team.16 // XTIDE Universal BIOS and Associated Tools 17 // Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team. 18 18 // 19 19 // This program is free software; you can redistribute it and/or modify … … 21 21 // the Free Software Foundation; either version 2 of the License, or 22 22 // (at your option) any later version. 23 // 23 // 24 24 // This program is distributed in the hope that it will be useful, 25 25 // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 26 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 // GNU General Public License for more details. 27 // GNU General Public License for more details. 28 28 // Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 29 29 // … … 44 44 return( 0 ); 45 45 } 46 46 47 47 if( !(fp = fopen( p_name, "w" )) ) 48 48 log( -1, "Could not create file '%s'", p_name ); 49 49 50 50 name = p_name; 51 51 52 52 return( 1 ); 53 53 } … … 108 108 } 109 109 110 const static unsigned long MaxSectors = 4194303; // limited by signed 32-bit file sizes 110 const static unsigned long MaxSectors = 4194303; // limited by signed 32-bit file sizes 111 111 #define USAGE_MAXSECTORS "2048 MB (signed 32-bit file size limit)" 112 112 -
trunk/Serial_Server/library/FlatImage.h
r376 r526 7 7 8 8 // 9 // XTIDE Universal BIOS and Associated Tools 10 // Copyright (C) 2009-2010 by Tomi Tilli, 2011-201 2by XTIDE Universal BIOS Team.9 // XTIDE Universal BIOS and Associated Tools 10 // Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team. 11 11 // 12 12 // This program is free software; you can redistribute it and/or modify … … 14 14 // the Free Software Foundation; either version 2 of the License, or 15 15 // (at your option) any later version. 16 // 16 // 17 17 // This program is distributed in the hope that it will be useful, 18 18 // but WITHOUT ANY WARRANTY; without even the implied warranty of 19 19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 // GNU General Public License for more details. 20 // GNU General Public License for more details. 21 21 // Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 22 22 // … … 47 47 sizef = size / 2048.0; // 512 byte sectors -> MB 48 48 sizeChar = 'M'; 49 if( sizef < 1 ) 49 if( sizef < 1 ) 50 50 { 51 51 sizef *= 1024; … … 58 58 while( size-- ) 59 59 cf.Write( &buff[0], 512 ); 60 60 61 61 if( p_cyl > 1024 ) 62 62 log( 0, "Created file '%s', size %.2lf %cB", name, sizef, sizeChar ); -
trunk/Serial_Server/library/Image.cpp
r430 r526 7 7 8 8 // 9 // XTIDE Universal BIOS and Associated Tools 10 // Copyright (C) 2009-2010 by Tomi Tilli, 2011-201 2by XTIDE Universal BIOS Team.9 // XTIDE Universal BIOS and Associated Tools 10 // Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team. 11 11 // 12 12 // This program is free software; you can redistribute it and/or modify … … 14 14 // the Free Software Foundation; either version 2 of the License, or 15 15 // (at your option) any later version. 16 // 16 // 17 17 // This program is distributed in the hope that it will be useful, 18 18 // but WITHOUT ANY WARRANTY; without even the implied warranty of 19 19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 // GNU General Public License for more details. 20 // GNU General Public License for more details. 21 21 // Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 22 22 // … … 28 28 #include <stdio.h> 29 29 30 struct floppyInfo floppyInfos[] = 30 struct floppyInfo floppyInfos[] = 31 31 { 32 32 { 1, 2949120 / 512, 6, 80, 2, 36 }, // 2.88MB 3.5" … … 89 89 shortFileName = "SerDrive"; 90 90 } 91 91 92 92 readOnly = p_readOnly; 93 93 drive = p_drive; … … 135 135 log( -1, "'%s', file size does not match standard CHS geometry (x:16:63), please specify geometry explicitly with -g", name ); 136 136 } 137 else 137 else 138 138 { 139 139 sect = 63; … … 151 151 sizef = totallba/2048.0; 152 152 sizeChar = 'M'; 153 if( sizef < 1 ) 153 if( sizef < 1 ) 154 154 { 155 155 sizef *= 1024; … … 160 160 name, (floppy ? "Floppy Disk" : "Hard Disk"), cyl, head, sect, sizef, sizeChar ); 161 161 else 162 log( 0, "%s: %s with %lu LBA sectors, size %.2lf %cB (CHS geometry %u:%u:%u)", 162 log( 0, "%s: %s with %lu LBA sectors, size %.2lf %cB (CHS geometry %u:%u:%u)", 163 163 name, (floppy ? "Floppy Disk" : "Hard Disk"), totallba, sizef, sizeChar, cyl, head, sect ); 164 164 } … … 176 176 *h = '\0'; 177 177 h++; 178 for( s = h+1; *s && *s != ':' && *s != 'x' && *s != 'X'; s++ ) ; 178 for( s = h+1; *s && *s != ':' && *s != 'x' && *s != 'X'; s++ ) ; 179 179 if( !*s ) 180 180 return( 0 ); … … 244 244 unsigned char com; 245 245 }; 246 struct comPorts supportedComPorts[] = 247 { 248 { 0x3f8, '1' }, 249 { 0x2f8, '2' }, 250 { 0x3e8, '3' }, 251 { 0x2e8, '4' }, 252 { 0x2f0, '5' }, 253 { 0x3e0, '6' }, 254 { 0x2e0, '7' }, 246 struct comPorts supportedComPorts[] = 247 { 248 { 0x3f8, '1' }, 249 { 0x2f8, '2' }, 250 { 0x3e8, '3' }, 251 { 0x2e8, '4' }, 252 { 0x2f0, '5' }, 253 { 0x3e0, '6' }, 254 { 0x2e0, '7' }, 255 255 { 0x260, '8' }, 256 256 { 0x368, '9' }, … … 258 258 { 0x360, 'B' }, 259 259 { 0x270, 'C' }, 260 { 0, 0 } 260 { 0, 0 } 261 261 }; 262 262 … … 310 310 } 311 311 312 // We echo back the port and baud that we were called on from the client, 312 // We echo back the port and baud that we were called on from the client, 313 313 // the client then uses this value to finalize the DPT. 314 314 // … … 321 321 buff[ ATA_wSerialDriveFlags ] = ATA_wSerialDriveFlags_Present; 322 322 if( floppy ) 323 buff[ ATA_wSerialDriveFlags ] |= 323 buff[ ATA_wSerialDriveFlags ] |= 324 324 ATA_wSerialDriveFlags_Floppy | (floppyType << ATA_wSerialDriveFlags_FloppyType_FieldPosition); 325 325 -
trunk/Serial_Server/library/Library.h
r376 r526 7 7 8 8 // 9 // XTIDE Universal BIOS and Associated Tools 10 // Copyright (C) 2009-2010 by Tomi Tilli, 2011-201 2by XTIDE Universal BIOS Team.9 // XTIDE Universal BIOS and Associated Tools 10 // Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team. 11 11 // 12 12 // This program is free software; you can redistribute it and/or modify … … 14 14 // the Free Software Foundation; either version 2 of the License, or 15 15 // (at your option) any later version. 16 // 16 // 17 17 // This program is distributed in the hope that it will be useful, 18 18 // but WITHOUT ANY WARRANTY; without even the implied warranty of 19 19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 // GNU General Public License for more details. 20 // GNU General Public License for more details. 21 21 // Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 22 22 // -
trunk/Serial_Server/library/Process.cpp
r376 r526 7 7 8 8 // 9 // XTIDE Universal BIOS and Associated Tools 10 // Copyright (C) 2009-2010 by Tomi Tilli, 2011-201 2by XTIDE Universal BIOS Team.9 // XTIDE Universal BIOS and Associated Tools 10 // Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team. 11 11 // 12 12 // This program is free software; you can redistribute it and/or modify … … 14 14 // the Free Software Foundation; either version 2 of the License, or 15 15 // (at your option) any later version. 16 // 16 // 17 17 // This program is distributed in the hope that it will be useful, 18 18 // but WITHOUT ANY WARRANTY; without even the implied warranty of 19 19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 // GNU General Public License for more details. 20 // GNU General Public License for more details. 21 21 // Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 22 22 // … … 179 179 lasttick = GetTime(); 180 180 181 // 181 // 182 182 // No work currently to do, look at each character as they come in... 183 183 // … … 289 289 if( (workCommand != SERIAL_COMMAND_INQUIRE) && (buff.chs.driveAndHead & ATA_COMMAND_LBA) ) 290 290 { 291 mylba = ((((unsigned long) buff.lba.bits24) & ATA_COMMAND_HEADMASK) << 24) 292 | (((unsigned long) buff.lba.bits16) << 16) 293 | (((unsigned long) buff.lba.bits08) << 8) 291 mylba = ((((unsigned long) buff.lba.bits24) & ATA_COMMAND_HEADMASK) << 24) 292 | (((unsigned long) buff.lba.bits16) << 16) 293 | (((unsigned long) buff.lba.bits08) << 8) 294 294 | ((unsigned long) buff.lba.bits00); 295 295 } … … 346 346 readto = 514; 347 347 } 348 else 348 else 349 349 { 350 350 // … … 355 355 unsigned char localScan; 356 356 357 if( serial->speedEmulation && 357 if( serial->speedEmulation && 358 358 buff.inquire.baud != serial->baudRate->divisor ) 359 359 { … … 363 363 } 364 364 365 localScan = buff.inquire.scan; // need to do this before the call to 365 localScan = buff.inquire.scan; // need to do this before the call to 366 366 // img->respondInquire, as it will clear the buff 367 img->respondInquire( &buff.w[0], buff.inquirePacked.PackedPortAndBaud, 368 serial->baudRate, 369 ((unsigned short) buff.inquire.port) << 2, 367 img->respondInquire( &buff.w[0], buff.inquirePacked.PackedPortAndBaud, 368 serial->baudRate, 369 ((unsigned short) buff.inquire.port) << 2, 370 370 (img == image1 && lastScan) || buff.inquire.scan ); 371 371 lastScan = localScan; -
trunk/Serial_Server/library/Serial.cpp
r488 r526 7 7 8 8 // 9 // XTIDE Universal BIOS and Associated Tools 10 // Copyright (C) 2009-2010 by Tomi Tilli, 2011-201 2by XTIDE Universal BIOS Team.9 // XTIDE Universal BIOS and Associated Tools 10 // Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team. 11 11 // 12 12 // This program is free software; you can redistribute it and/or modify … … 14 14 // the Free Software Foundation; either version 2 of the License, or 15 15 // (at your option) any later version. 16 // 16 // 17 17 // This program is distributed in the hope that it will be useful, 18 18 // but WITHOUT ANY WARRANTY; without even the implied warranty of 19 19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 // GNU General Public License for more details. 20 // GNU General Public License for more details. 21 21 // Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 22 22 // … … 26 26 #include <string.h> 27 27 28 struct baudRate supportedBaudRates[] = 29 { 28 struct baudRate supportedBaudRates[] = 29 { 30 30 { 2400, 0x30, "2400" }, 31 31 { 4800, 0x18, "4800" }, … … 47 47 { 48 48 struct baudRate *b; 49 49 50 50 unsigned long a = atol( str ); 51 51 if( a ) … … 63 63 struct baudRate *b; 64 64 65 for( b = supportedBaudRates; b->rate && b->divisor != divisor; b++ ) 65 for( b = supportedBaudRates; b->rate && b->divisor != divisor; b++ ) 66 66 ; 67 67
Note:
See TracChangeset
for help on using the changeset viewer.