Changeset 277 in xtideuniversalbios for trunk/Serial_Server


Ignore:
Timestamp:
Feb 28, 2012, 2:45:48 PM (12 years ago)
Author:
gregli@…
google:author:
gregli@hotmail.com
Message:

Moved the bulk of the serial code to the assembly library, for inclusion in other utilities. Fixed a bug in int13h.asm when floppy support was not enabled that was preventing foreign drives from working properly.

Location:
trunk/Serial_Server/library
Files:
3 edited

Legend:

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

    r259 r277  
    3838
    3939    return( fi );
     40}
     41
     42void flipEndian( unsigned short *buff, unsigned int len )
     43{
     44    for( unsigned int t = 0; t < len/2; t++ )
     45        buff[t] = (buff[t] & 0xff) << 8 | (buff[t] & 0xff00) >> 8;
    4046}
    4147
     
    178184#define ATA_wBpSect 5
    179185#define ATA_wSPT 6
     186
    180187#define ATA_strSerial 10
     188#define ATA_strSerial_Length 20
     189
    181190#define ATA_strFirmware 23
     191#define ATA_strFirmware_Length 8
     192
    182193#define ATA_strModel 27
     194#define ATA_strModel_Length 40
     195
    183196#define ATA_wCaps 49
    184197#define ATA_wCurCyls 54
     
    190203// Words carved out of the vendor specific area for our use
    191204//
     205#define ATA_wSerialServerVersion 157
    192206#define ATA_wSerialFloppyFlagAndType 158
    193207#define ATA_wSerialPortAndBaud 159
     
    223237};
    224238
    225 void Image::respondInquire( unsigned short *buff, struct baudRate *baudRate, unsigned short port, unsigned char scan )
    226 {
     239void Image::respondInquire( unsigned short *buff, unsigned short originalPortAndBaud, struct baudRate *baudRate, unsigned short port, unsigned char scan )
     240{
     241    char formatBuff[ 128 ];
     242
    227243    memset( &buff[0], 0, 514 );
    228244
     
    240256
    241257        if( comPort )
    242             sprintf( (char *) &buff[ATA_strModel], "%.15s (COM%c/%s)", shortFileName, comPort, baudRate->display );
     258            sprintf( formatBuff, "%.15s (COM%c/%s) ", shortFileName, comPort, baudRate->display );
    243259        else
    244             sprintf( (char *) &buff[ATA_strModel], "%.25s (%s baud)", shortFileName, baudRate->display );
     260            sprintf( formatBuff, "%.25s (%s baud) ", shortFileName, baudRate->display );
    245261    }
    246262    else
    247         sprintf( (char *) &buff[ATA_strModel], "%.30s", shortFileName );
    248 
    249     strncpy( (char *) &buff[ATA_strSerial], "serial", 20 );
    250     strncpy( (char *) &buff[ATA_strFirmware], "firmw", 8 );
    251 
    252     for( int t = ATA_strModel; t < ATA_strModel+40; t++ )
    253         buff[t] = (buff[t] >> 8) | (buff[t] << 8);
     263        sprintf( formatBuff, "%.30s ", shortFileName );
     264    strncpy( (char *) &buff[ATA_strModel], formatBuff, ATA_strModel_Length );
     265    flipEndian( &buff[ATA_strModel], ATA_strModel_Length );
     266
     267    strncpy( (char *) &buff[ATA_strSerial], "SerialDrive ", ATA_strSerial_Length );
     268    flipEndian( &buff[ATA_strSerial], ATA_strSerial_Length );
     269
     270    sprintf( formatBuff, "%d.%d ", SERIAL_SERVER_MAJORVERSION, SERIAL_SERVER_MINORVERSION );
     271    strncpy( (char *) &buff[ATA_strFirmware], formatBuff, ATA_strFirmware_Length );
     272    flipEndian( &buff[ATA_strFirmware], ATA_strFirmware_Length );
    254273
    255274    if( useCHS )
     
    266285    }
    267286
     287    // We echo back the port and baud that we were called on from the client,
     288    // the client then uses this value to finalize the DPT.
     289    //
     290    buff[ ATA_wSerialPortAndBaud ] = originalPortAndBaud;
     291
     292    // In case the client requires a specific server version...
     293    //
     294    buff[ ATA_wSerialServerVersion ] = (SERIAL_SERVER_MAJORVERSION << 8) | SERIAL_SERVER_MINORVERSION;
     295
    268296    if( floppy )
    269         buff[ ATA_wSerialFloppyFlagAndType ] = ATA_wSerialFloppyFlagAndType_Flag | (floppyType << ATA_wSerialFloppyFlagAndType_TypePosition);
     297        buff[ ATA_wSerialFloppyFlagAndType ] =
     298            ATA_wSerialFloppyFlagAndType_Flag | (floppyType << ATA_wSerialFloppyFlagAndType_TypePosition);
    270299
    271300    // we always set this, so that the bulk of the BIOS will consider this disk as a hard disk
  • trunk/Serial_Server/library/Library.h

    r259 r277  
    88#ifndef LIBRARY_H_INCLUDED
    99#define LIBRARY_H_INCLUDED
     10
     11#define SERIAL_SERVER_MAJORVERSION 1
     12#define SERIAL_SERVER_MINORVERSION 0
    1013
    1114void log( int level, char *message, ... );
     
    5457    static int parseGeometry( char *str, unsigned long *p_cyl, unsigned long *p_head, unsigned long *p_sect );
    5558
    56     void respondInquire( unsigned short *buff, struct baudRate *baudRate, unsigned short port, unsigned char scan );
     59    void respondInquire( unsigned short *buff, unsigned short originalPortAndBaud, struct baudRate *baudRate, unsigned short port, unsigned char scan );
    5760
    5861    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

    r258 r277  
    3535        unsigned char baud;
    3636    } inquire;
     37    struct {
     38        unsigned char command;
     39        unsigned char driveAndHead;
     40        unsigned char count;
     41        unsigned char scan;
     42        unsigned short PackedPortAndBaud;
     43    } inquirePacked;
    3744    unsigned char b[514];
    3845    unsigned short w[257];
     
    342349                    localScan = buff.inquire.scan;         // need to do this before the call to
    343350                                                           // img->respondInquire, as it will clear the buff
    344                     img->respondInquire( &buff.w[0], serial->baudRate,
     351                    img->respondInquire( &buff.w[0], buff.inquirePacked.PackedPortAndBaud,
     352                                         serial->baudRate,
    345353                                         ((unsigned short) buff.inquire.port) << 2,
    346354                                         (img == image1 && lastScan) || buff.inquire.scan );
Note: See TracChangeset for help on using the changeset viewer.