Changeset 526 in xtideuniversalbios for trunk/Serial_Server


Ignore:
Timestamp:
Mar 15, 2013, 1:38:58 AM (12 years ago)
Author:
krille_n_@…
google:author:
krille_n_@hotmail.com
Message:

Changes:

  • Update of the copyright notices to include the year 2013.
Location:
trunk/Serial_Server
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Serial_Server/library/Checksum.cpp

    r376 r526  
    66
    77//
    8 // XTIDE Universal BIOS and Associated Tools 
    9 // Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by 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.
    1010//
    1111// This program is free software; you can redistribute it and/or modify
     
    1313// the Free Software Foundation; either version 2 of the License, or
    1414// (at your option) any later version.
    15 // 
     15//
    1616// This program is distributed in the hope that it will be useful,
    1717// but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818// 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.
    2020// Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    2121//
    2222
    2323//
    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
    2525// to calculate in assembly and offers reasonable error detection.
    2626// For more information, see http://en.wikipedia.org/wiki/Fletcher%27s_checksum.
    2727//
    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,
    2929// 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
    3232// the two results concatenated together, resulting in 16-bits.  Although simpler, an early attempt to XOR the
    3333// 16-bit accumulators results in poorer error detection behavior.  Folding as described here results in error
     
    3535//
    3636// 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
    3838// levels of errors introduced.
    3939//
     
    5858    b = (b & 0xffff) + (b >> 16);
    5959
    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
    6161// algorithm results in many undetected single bit errors and therefore should not be used.
    6262//  return( (unsigned short) (a ^ b) );
     
    6868
    6969//====================================================================================================
    70 // 
     70//
    7171// Test Code
    7272//
     
    8282unsigned char bit[] = { 1, 2, 4, 8, 16, 32, 64, 128 };
    8383
    84 class algorithm 
     84class algorithm
    8585{
    8686public:
     
    113113
    114114//----------------------------------------------------------------------------------------------------
    115 // 
     115//
    116116// Standard CRC-16
    117117//
     
    131131        unsigned short j;
    132132
    133         for(i = 0; i < 256; ++i) 
     133        for(i = 0; i < 256; ++i)
    134134        {
    135135            value = 0;
     
    147147    }
    148148
    149     unsigned short checksum( unsigned char *data, int len ); 
     149    unsigned short checksum( unsigned char *data, int len );
    150150
    151151private:
     
    158158    int i;
    159159
    160     for(i = 0; i < len; ++i) 
     160    for(i = 0; i < len; ++i)
    161161    {
    162162        unsigned char index = (unsigned char)(crc ^ data[i]);
     
    168168
    169169//----------------------------------------------------------------------------------------------------
    170 // 
     170//
    171171// Basic checksum (just add up the bytes)
    172172//
     
    175175{
    176176public:
    177     unsigned short checksum( unsigned char *data, int len ); 
     177    unsigned short checksum( unsigned char *data, int len );
    178178    basic_algorithm( algorithm *last ) : algorithm( last, (char *) "basic" ) { };
    179179};
     
    193193{
    194194public:
    195     unsigned short checksum( unsigned char *data, int len ); 
     195    unsigned short checksum( unsigned char *data, int len );
    196196    fletcher16_algorithm( algorithm *last ) : algorithm( last, (char *) "f-16" ) { }
    197197};
     
    213213
    214214//----------------------------------------------------------------------------------------------------
    215 // 
     215//
    216216// Folded Fletcher's Checksum (what we use in the serial code, from the top of this file)
    217217//
     
    220220{
    221221public:
    222     unsigned short checksum( unsigned char *data, int len ); 
     222    unsigned short checksum( unsigned char *data, int len );
    223223    folded_fletcher32_algorithm( algorithm *last ) : algorithm( last, (char *) "fold-f-32" ) { }
    224224};
     
    230230
    231231//----------------------------------------------------------------------------------------------------
    232 // 
     232//
    233233// Test Driver and Support routines
    234234//
     
    283283    {
    284284        a->found = (unsigned long *) calloc( BUCKETS, sizeof(long) );
    285        
     285
    286286        a->zero = (unsigned long) a->checksum( bbuff, BBUFF_LENGTH );
    287287
    288288        a->min = iterations+1;
    289289    }
    290    
     290
    291291    printf( "\n" );
    292292    PRINTROW( "zero   ", "%10d  ", a->zero );
     
    344344
    345345            bbuff[ rand() % 512 ] ^= bit[ rand() % 8 ];
    346            
     346
    347347            if( b > 0 )
    348348            {
     
    354354            }
    355355        }
    356     } 
     356    }
    357357
    358358    printf( "\nbit change test:\n" );
  • trunk/Serial_Server/library/File.h

    r376 r526  
    66//
    77// 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
    99// 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
    1212// win32/win32file.h which may be in use instead.
    13 // 
     13//
    1414
    1515//
    16 // XTIDE Universal BIOS and Associated Tools 
    17 // Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by 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.
    1818//
    1919// This program is free software; you can redistribute it and/or modify
     
    2121// the Free Software Foundation; either version 2 of the License, or
    2222// (at your option) any later version.
    23 // 
     23//
    2424// This program is distributed in the hope that it will be useful,
    2525// but WITHOUT ANY WARRANTY; without even the implied warranty of
    2626// 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.
    2828// Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    2929//
     
    4444            return( 0 );
    4545        }
    46        
     46
    4747        if( !(fp = fopen( p_name, "w" )) )
    4848            log( -1, "Could not create file '%s'", p_name );
    4949
    5050        name = p_name;
    51        
     51
    5252        return( 1 );
    5353    }
     
    108108    }
    109109
    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
    111111#define USAGE_MAXSECTORS "2048 MB (signed 32-bit file size limit)"
    112112
  • trunk/Serial_Server/library/FlatImage.h

    r376 r526  
    77
    88//
    9 // XTIDE Universal BIOS and Associated Tools 
    10 // Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by 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.
    1111//
    1212// This program is free software; you can redistribute it and/or modify
     
    1414// the Free Software Foundation; either version 2 of the License, or
    1515// (at your option) any later version.
    16 // 
     16//
    1717// This program is distributed in the hope that it will be useful,
    1818// but WITHOUT ANY WARRANTY; without even the implied warranty of
    1919// 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.
    2121// Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    2222//
     
    4747            sizef = size / 2048.0;   // 512 byte sectors -> MB
    4848            sizeChar = 'M';
    49             if( sizef < 1 ) 
     49            if( sizef < 1 )
    5050            {
    5151                sizef *= 1024;
     
    5858                while( size-- )
    5959                    cf.Write( &buff[0], 512 );
    60                
     60
    6161                if( p_cyl > 1024 )
    6262                    log( 0, "Created file '%s', size %.2lf %cB", name, sizef, sizeChar );
  • trunk/Serial_Server/library/Image.cpp

    r430 r526  
    77
    88//
    9 // XTIDE Universal BIOS and Associated Tools 
    10 // Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by 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.
    1111//
    1212// This program is free software; you can redistribute it and/or modify
     
    1414// the Free Software Foundation; either version 2 of the License, or
    1515// (at your option) any later version.
    16 // 
     16//
    1717// This program is distributed in the hope that it will be useful,
    1818// but WITHOUT ANY WARRANTY; without even the implied warranty of
    1919// 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.
    2121// Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    2222//
     
    2828#include <stdio.h>
    2929
    30 struct floppyInfo floppyInfos[] = 
     30struct floppyInfo floppyInfos[] =
    3131{
    3232    { 1, 2949120 / 512, 6, 80, 2, 36 },         // 2.88MB 3.5"
     
    8989        shortFileName = "SerDrive";
    9090    }
    91  
     91
    9292    readOnly = p_readOnly;
    9393    drive = p_drive;
     
    135135            log( -1, "'%s', file size does not match standard CHS geometry (x:16:63), please specify geometry explicitly with -g", name );
    136136        }
    137         else 
     137        else
    138138        {
    139139            sect = 63;
     
    151151    sizef = totallba/2048.0;
    152152    sizeChar = 'M';
    153     if( sizef < 1 ) 
     153    if( sizef < 1 )
    154154    {
    155155        sizef *= 1024;
     
    160160             name, (floppy ? "Floppy Disk" : "Hard Disk"), cyl, head, sect, sizef, sizeChar );
    161161    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)",
    163163             name, (floppy ? "Floppy Disk" : "Hard Disk"), totallba, sizef, sizeChar, cyl, head, sect );
    164164}
     
    176176    *h = '\0';
    177177    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++ ) ;
    179179    if( !*s )
    180180        return( 0 );
     
    244244    unsigned char com;
    245245};
    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' }, 
     246struct comPorts supportedComPorts[] =
     247{
     248  { 0x3f8, '1' },
     249  { 0x2f8, '2' },
     250  { 0x3e8, '3' },
     251  { 0x2e8, '4' },
     252  { 0x2f0, '5' },
     253  { 0x3e0, '6' },
     254  { 0x2e0, '7' },
    255255  { 0x260, '8' },
    256256  { 0x368, '9' },
     
    258258  { 0x360, 'B' },
    259259  { 0x270, 'C' },
    260   { 0, 0 } 
     260  { 0, 0 }
    261261};
    262262
     
    310310    }
    311311
    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,
    313313    // the client then uses this value to finalize the DPT.
    314314    //
     
    321321    buff[ ATA_wSerialDriveFlags ] = ATA_wSerialDriveFlags_Present;
    322322    if( floppy )
    323         buff[ ATA_wSerialDriveFlags ] |= 
     323        buff[ ATA_wSerialDriveFlags ] |=
    324324            ATA_wSerialDriveFlags_Floppy | (floppyType << ATA_wSerialDriveFlags_FloppyType_FieldPosition);
    325325
  • trunk/Serial_Server/library/Library.h

    r376 r526  
    77
    88//
    9 // XTIDE Universal BIOS and Associated Tools 
    10 // Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by 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.
    1111//
    1212// This program is free software; you can redistribute it and/or modify
     
    1414// the Free Software Foundation; either version 2 of the License, or
    1515// (at your option) any later version.
    16 // 
     16//
    1717// This program is distributed in the hope that it will be useful,
    1818// but WITHOUT ANY WARRANTY; without even the implied warranty of
    1919// 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.
    2121// Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    2222//
  • trunk/Serial_Server/library/Process.cpp

    r376 r526  
    77
    88//
    9 // XTIDE Universal BIOS and Associated Tools 
    10 // Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by 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.
    1111//
    1212// This program is free software; you can redistribute it and/or modify
     
    1414// the Free Software Foundation; either version 2 of the License, or
    1515// (at your option) any later version.
    16 // 
     16//
    1717// This program is distributed in the hope that it will be useful,
    1818// but WITHOUT ANY WARRANTY; without even the implied warranty of
    1919// 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.
    2121// Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    2222//
     
    179179        lasttick = GetTime();
    180180
    181         // 
     181        //
    182182        // No work currently to do, look at each character as they come in...
    183183        //
     
    289289                if( (workCommand != SERIAL_COMMAND_INQUIRE) && (buff.chs.driveAndHead & ATA_COMMAND_LBA) )
    290290                {
    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)
    294294                        | ((unsigned long) buff.lba.bits00);
    295295                }
     
    346346                readto = 514;
    347347            }
    348             else 
     348            else
    349349            {
    350350                //
     
    355355                    unsigned char localScan;
    356356
    357                     if( serial->speedEmulation && 
     357                    if( serial->speedEmulation &&
    358358                        buff.inquire.baud != serial->baudRate->divisor )
    359359                    {
     
    363363                    }
    364364
    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
    366366                                                           // 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,
    370370                                         (img == image1 && lastScan) || buff.inquire.scan );
    371371                    lastScan = localScan;
  • trunk/Serial_Server/library/Serial.cpp

    r488 r526  
    77
    88//
    9 // XTIDE Universal BIOS and Associated Tools 
    10 // Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by 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.
    1111//
    1212// This program is free software; you can redistribute it and/or modify
     
    1414// the Free Software Foundation; either version 2 of the License, or
    1515// (at your option) any later version.
    16 // 
     16//
    1717// This program is distributed in the hope that it will be useful,
    1818// but WITHOUT ANY WARRANTY; without even the implied warranty of
    1919// 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.
    2121// Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    2222//
     
    2626#include <string.h>
    2727
    28 struct baudRate supportedBaudRates[] = 
    29 { 
     28struct baudRate supportedBaudRates[] =
     29{
    3030    {   2400,  0x30,    "2400" },
    3131    {   4800,  0x18,    "4800" },
     
    4747{
    4848    struct baudRate *b;
    49  
     49
    5050    unsigned long a = atol( str );
    5151    if( a )
     
    6363    struct baudRate *b;
    6464
    65     for( b = supportedBaudRates; b->rate && b->divisor != divisor; b++ ) 
     65    for( b = supportedBaudRates; b->rate && b->divisor != divisor; b++ )
    6666        ;
    6767
  • trunk/Serial_Server/win32/Win32.cpp

    r488 r526  
    77// This file contains the entry point for the Win32 version of the server.
    88// It also handles log reporting, timers, and command line parameter parsing.
    9 // 
    10 
    11 //
    12 // XTIDE Universal BIOS and Associated Tools 
    13 // Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
     9//
     10
     11//
     12// XTIDE Universal BIOS and Associated Tools
     13// Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
    1414//
    1515// This program is free software; you can redistribute it and/or modify
     
    1717// the Free Software Foundation; either version 2 of the License, or
    1818// (at your option) any later version.
    19 // 
     19//
    2020// This program is distributed in the hope that it will be useful,
    2121// but WITHOUT ANY WARRANTY; without even the implied warranty of
    2222// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    23 // GNU General Public License for more details.     
     23// GNU General Public License for more details.
    2424// Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    2525//
     
    3737char *bannerStrings[] = {
    3838    "SerDrive - XTIDE Universal BIOS Serial Drive Server",
    39     "Copyright (C) 2012 by XTIDE Universal BIOS Team",
     39    "Copyright (C) 2012-2013 by XTIDE Universal BIOS Team",
    4040    "Released under GNU GPL v2, with ABSOLUTELY NO WARRANTY",
    4141    ROM_VERSION_STRING,
    42     "", 
     42    "",
    4343    NULL };
    4444
     
    5858    "",
    5959    "  -n [megabytes]      Create new disk with given size or use -g geometry",
    60     "                      Maximum size is " USAGE_MAXSECTORS, 
     60    "                      Maximum size is " USAGE_MAXSECTORS,
    6161    "                      Floppy images can also be created, such as \"360K\"",
    6262    "                      (default is a 32 MB disk, with CHS geometry 65:16:63)",
     
    152152            char *c;
    153153            unsigned long a;
    154             for( c = &argv[t][1]; *c && !isdigit( *c ); c++ ) 
     154            for( c = &argv[t][1]; *c && !isdigit( *c ); c++ )
    155155                ;
    156156            a = atol(c);
     
    190190                if( !baudRate )
    191191                    baudRate = baudRateMatchString( "115200" );
    192                 break;           
     192                break;
    193193            case 'g': case 'G':
    194194                if( next && atol(next) != 0 )
  • trunk/Serial_Server/win32/Win32File.h

    r505 r526  
    1313//
    1414// XTIDE Universal BIOS and Associated Tools
    15 // Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
     15// Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
    1616//
    1717// This program is free software; you can redistribute it and/or modify
  • trunk/Serial_Server/win32/Win32Serial.h

    r376 r526  
    77
    88//
    9 // XTIDE Universal BIOS and Associated Tools 
    10 // Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by 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.
    1111//
    1212// This program is free software; you can redistribute it and/or modify
     
    1414// the Free Software Foundation; either version 2 of the License, or
    1515// (at your option) any later version.
    16 // 
     16//
    1717// This program is distributed in the hope that it will be useful,
    1818// but WITHOUT ANY WARRANTY; without even the implied warranty of
    1919// 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.
    2121// Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    2222//
Note: See TracChangeset for help on using the changeset viewer.