Changeset 233 in xtideuniversalbios for trunk/Serial_Server


Ignore:
Timestamp:
Feb 4, 2012, 6:21:22 PM (13 years ago)
Author:
gregli@…
google:author:
gregli@hotmail.com
Message:

Serial Port: split single byte port and baud into two bytes, taking advantage of the two bytes in DPT_SERIAL, which supports more serial baud rates and in particular fixed a bug where a 4x client machine couldn't talk to a 115.2K server machine. This is a wide change, touching lots of files, but most are shallow changes. DetectPrint.asm took the most significant changes, now it calculates the baud rate to display instead of using characters provided by the Configurator. The Configurator now has a new menu flag, FLG_MENUITEM_CHOICESTRINGS, for specifying that values are not linear and they should be lookedup rather than indexed. Finally, another important bug fixed here is that in some error cases, the serial port code could get into an infinite loop waiting ont the hardware; now it has a timeout.

Location:
trunk/Serial_Server
Files:
6 edited

Legend:

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

    r219 r233  
    137137#define ATA_dwLBACnt 60
    138138
    139 #define ATA_VendorSpecific_ReturnPortBaud 158
     139#define ATA_wVendor 159
    140140
    141141#define ATA_wCaps_LBA 0x200
     
    164164};
    165165
    166 void Image::respondInquire( unsigned short *buff, struct baudRate *baudRate, unsigned char portAndBaud )
    167 {
    168     unsigned short comPort = 0;
    169     struct comPorts *cp;
    170 
    171     if( portAndBaud )
    172     {
    173         for( cp = supportedComPorts; cp->port && cp->port != ((portAndBaud << 3) + 0x260); cp++ ) ;
    174         if( cp->port )
    175             comPort = cp->com;
    176     }
    177      
     166void Image::respondInquire( unsigned short *buff, struct baudRate *baudRate, unsigned short port, unsigned char scan )
     167{
    178168    memset( &buff[0], 0, 514 );
    179169
    180     if( comPort )
    181         sprintf( (char *) &buff[ATA_strModel], "%.20s (COM%d/%s)", shortFileName, comPort, baudRate->display );
    182     else
    183         sprintf( (char *) &buff[ATA_strModel], "%.30s (%s baud)", shortFileName, baudRate->display );
    184 
    185     // strncpy( (char *) &buff[ATA_strModel], img->shortFileName, 40 );
     170    if( scan )
     171    {
     172        unsigned short comPort = 0;
     173        struct comPorts *cp;
     174
     175        if( port )
     176        {
     177            for( cp = supportedComPorts; cp->port && cp->port != port; cp++ ) ;
     178            if( cp->port )
     179                comPort = cp->com;
     180        }
     181
     182        if( comPort )
     183            sprintf( (char *) &buff[ATA_strModel], "%.15s (COM%c/%s)", shortFileName, comPort, baudRate->display );
     184        else
     185            sprintf( (char *) &buff[ATA_strModel], "%.25s (%s baud)", shortFileName, baudRate->display );
     186    }
     187    else
     188        sprintf( (char *) &buff[ATA_strModel], "%.30s", shortFileName );
    186189
    187190    strncpy( (char *) &buff[ATA_strSerial], "serial", 20 );
  • trunk/Serial_Server/library/Library.h

    r223 r233  
    4242    static int parseGeometry( char *str, unsigned long *p_cyl, unsigned long *p_head, unsigned long *p_sect );
    4343
    44     void respondInquire( unsigned short *buff, struct baudRate *baudRate, unsigned char portAndBaud );
     44    void respondInquire( unsigned short *buff, struct baudRate *baudRate, unsigned short port, unsigned char scan );
    4545
    4646    void init( char *name, int p_readOnly, int p_drive, unsigned long p_cyl, unsigned long p_head, unsigned long p_sect, int p_useCHS );
  • trunk/Serial_Server/library/Process.cpp

    r219 r233  
    3131        unsigned char driveAndHead;
    3232        unsigned char count;
    33         unsigned char undefined1;
    34         unsigned char portAndBaud;
    35         unsigned char undefined2;
     33        unsigned char scan;
     34        unsigned char port;
     35        unsigned char baud;
    3636    } inquire;
    3737    unsigned char b[514];
     
    4848#define SERIAL_COMMAND_MASK 0xe3
    4949#define SERIAL_COMMAND_HEADERMASK 0xe0
    50 
    51 #define SERIAL_INQUIRE_PORTANDBAUD_BAUDMASK 3
    52 #define SERIAL_INQUIRE_PORTANDBAUD_PORTMASK 0xfc
    53 #define SERIAL_INQUIRE_PORTANDBAUD_STARTINGPORT 0x240
    54 
    55 #define SERIAL_INQUIRE_PORTANDBAUD_PORTTRANSLATE( a ) ( ((a) & SERIAL_INQUIRE_PORTANDBAUD_PORT) << 1 | SERIAL_INQUIRE_PORTANDBAUD_STARTINGPORT )
    5650
    5751#define ATA_COMMAND_LBA 0x40
     
    9690    unsigned long cyl, sect, head;
    9791    unsigned long perfTimer;
     92    unsigned char lastScan;
    9893
    9994    GetTime_Timeout_Local = GetTime_Timeout();
     
    10297    readto = 0;
    10398    workCount = workOffset = workCommand = 0;
     99    lastScan = 0;
    104100
    105101    lasttick = GetTime();
     
    282278                    if( workCommand == SERIAL_COMMAND_INQUIRE )
    283279                        log( 1, "Inquire %d: Client Port=0x%x, Client Baud=%s", img == image0 ? 0 : 1,
    284                              ((buff.inquire.portAndBaud & SERIAL_INQUIRE_PORTANDBAUD_PORTMASK) << 1)
    285                              + SERIAL_INQUIRE_PORTANDBAUD_STARTINGPORT,
    286                              baudRateMatchDivisor( buff.inquire.portAndBaud & SERIAL_INQUIRE_PORTANDBAUD_BAUDMASK )->display );
     280                             ((unsigned short) buff.inquire.port) << 2,
     281                             baudRateMatchDivisor( buff.inquire.baud )->display );
    287282                    else if( buff.chs.driveAndHead & ATA_COMMAND_LBA )
    288283                        log( 1, "%s %d: LBA=%u, Count=%u", comStr, img == image0 ? 0 : 1,
     
    325320                if( workCommand == SERIAL_COMMAND_INQUIRE )
    326321                {
     322                    unsigned char localScan;
     323
    327324                    if( serial->speedEmulation &&
    328                         (buff.inquire.portAndBaud & SERIAL_INQUIRE_PORTANDBAUD_BAUDMASK) != serial->baudRate->divisor )
     325                        buff.inquire.baud != serial->baudRate->divisor )
    329326                    {
    330327                        log( 1, "    Ignoring Inquire with wrong baud rate" );
     
    333330                    }
    334331
    335                     img->respondInquire( &buff.w[0], serial->baudRate, buff.inquire.portAndBaud );
     332                    localScan = buff.inquire.scan;         // need to do this before the call to
     333                                                           // img->respondInquire, as it will clear the buff
     334                    img->respondInquire( &buff.w[0], serial->baudRate,
     335                                         ((unsigned short) buff.inquire.port) << 2,
     336                                         (img == image1 && lastScan) || buff.inquire.scan );
     337                    lastScan = localScan;
    336338                }
    337339                //
     
    342344                    img->seekSector( mylba + workOffset );
    343345                    img->readSector( &buff.w[0] );
     346                    lastScan = 0;
    344347                }
    345348
  • trunk/Serial_Server/library/Serial.cpp

    r215 r233  
    1212struct baudRate supportedBaudRates[] =
    1313{
    14     {   2400,  0x0,   "2400" },
    15     {   4800, 0xff,   "4800" },
    16     {   9600,  0x1,   "9600" },
    17     {  19200, 0xff,  "19.2K" },
    18     {  38400,  0x2,  "38.4K" },
    19     {  76800, 0xff,  "76.8K" },
    20     { 115200,  0x3, "115.2K" },
    21     { 153600, 0xff, "153.6K" },
    22     { 230400, 0xff, "230.4K" },
    23     { 460800, 0xff, "460.8K" },
    24     {      0,    0,     NULL }
     14    {   2400,  0x30,    "2400" },
     15    {   4800,  0x18,    "4800" },
     16    {   9600,   0xc,    "9600" },
     17    {  19200,  0xff,   "19.2K" },
     18    {  28800,   0x4,   "28.8K" },
     19    {  38400,  0xff,   "38.4K" },
     20    {  57600,   0x2,   "57.6K" },
     21    {  76800,  0xff,   "76.8K" },
     22    { 115200,   0x1,  "115.2K" },
     23    { 153600,  0xff,  "153.6K" },
     24    { 230400,  0xff,  "230.4K" },
     25    { 460800,  0xff,  "460.8K" },
     26    {      0,     0, "Unknown" },
    2527};
    2628
     
    3739    }
    3840
    39     return( NULL );
     41    return( b );
    4042}
    4143
     
    4749        ;
    4850
    49     return( b->rate ? b : NULL );
     51    return( b );
    5052}
    5153
  • trunk/Serial_Server/win32/Win32.cpp

    r225 r233  
    3232        "                      (default is a 32 MB disk, with CHS geometry 65:63:16)",
    3333        "",
    34         "  -p                  Named Pipe mode for emulators (pipe is '" PIPENAME "')",
     34        "  -p                  Named Pipe mode for emulators (pipe is \"" PIPENAME "\")",
    3535        "",
    3636        "  -c COMPortNumber    COM Port to use (default is first found)",
    3737        "",
    38         "  -b BaudRate         Baud rate to use on the COM port ",
    39         "                      Without a rate multiplier: 2400, 9600, 38400, 115200",
    40         "                      With a 2x rate multiplier: 4800, 19200, 76800, 230400",
    41         "                      With a 4x rate multiplier: 9600, 38400, 153600, 460800",
    42         "                      Abbreviations also accepted (ie, '460K', '38.4K', etc)",
    43         "                      (default is 38400, 115200 in named pipe mode)",
     38        "  -b BaudRate         Baud rate to use on the COM port, with client machine",
     39        "                      rate multiplier in effect:",
     40        "                          None:  2400,  4800,  9600,  28.8K,  57.6K, 115.2K",
     41        "                          2x:    4800,  9600, 19200,  57.6K, 115.2K, 230.4K",
     42        "                          4x:    9600, 19200, 38400, 115.2K, 230.4K, 460.8K",
     43        "                          and for completeness:               76.8K, 153.6K",
     44        "                      (default is 9600, 115.2K when in named pipe mode)",
    4445        "",
    4546        "  -t                  Disable timeout, useful for long delays when debugging",
     
    148149                break;
    149150            case 'b': case 'B':
    150                 if( !(baudRate = baudRateMatchString( argv[++t] )) )
    151                 {
    152                     fprintf( stderr, "Unknown Baud Rate %s\n\n", argv[t] );
    153                     usage();
    154                 }
     151                if( !(baudRate = baudRateMatchString( argv[++t] )) || !baudRate->rate )
     152                    log( -2, "Unknown Baud Rate \"%s\"", argv[t] );
    155153                break;
    156154            default:
    157                 fprintf( stderr, "Unknown Option: %s\n\n", argv[t] );
    158                 usage();
     155                log( -2, "Unknown Option: \"%s\"", argv[t] );
    159156            }
    160157        }
     
    179176
    180177    if( !baudRate )
    181         baudRate = baudRateMatchString( "38400" );
     178        baudRate = baudRateMatchString( "9600" );
    182179
    183180    do
     
    206203        vfprintf( stderr, message, args );
    207204        fprintf( stderr, "\n" );
     205        if( level < -1 )
     206        {
     207            fprintf( stderr, "\n" );
     208            usage();
     209        }
    208210        exit( 1 );
    209211    }
  • trunk/Serial_Server/win32/Win32Serial.h

    r225 r233  
    3737        if( !strcmp( name, "PIPE" ) )
    3838        {
    39             log( 0, "Opening named pipe %s (simulating %lu baud)", PIPENAME, baudRate->rate );
     39            log( 0, "Opening named pipe %s (simulating %s baud)", PIPENAME, baudRate->display );
    4040       
    4141            pipe = CreateNamedPipeA( PIPENAME, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE|PIPE_REJECT_REMOTE_CLIENTS, 2, 1024, 1024, 0, NULL );
Note: See TracChangeset for help on using the changeset viewer.